comparison Tests/Tests.py @ 96:272d1229cb49

test reconstruction of tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 09 Dec 2016 17:12:00 +0100
parents a807a4699eb4
children 2af6c0fb850d 9daaf841c17c
comparison
equal deleted inserted replaced
95:a807a4699eb4 96:272d1229cb49
3089 'Query' : { }}) 3089 'Query' : { }})
3090 self.assertEqual(1, len(a)) 3090 self.assertEqual(1, len(a))
3091 3091
3092 tmp = ENCODINGS[name][1] 3092 tmp = ENCODINGS[name][1]
3093 self.assertEqual(TEST.encode(tmp, 'ignore').decode(tmp), a[0]["PatientMainDicomTags"]["PatientName"]) 3093 self.assertEqual(TEST.encode(tmp, 'ignore').decode(tmp), a[0]["PatientMainDicomTags"]["PatientName"])
3094
3095
3096 def test_reconstruct(self):
3097 def CompareMainDicomTag(expected, instance, level, tag):
3098 self.assertEqual(expected, DoGet(_REMOTE, '/instances/%s/%s' % (instance, level))['MainDicomTags'][tag].strip())
3099
3100 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID']
3101
3102 studies = DoGet(_REMOTE, '/studies/')
3103 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/')))
3104 self.assertEqual(1, len(studies))
3105 self.assertEqual(1, len(DoGet(_REMOTE, '/series/')))
3106 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/')))
3107
3108 modified = DoPost(_REMOTE, '/studies/%s/modify' % studies[0], {
3109 "Replace" : {
3110 "StudyDescription" : "hello",
3111 "SeriesDescription" : "world",
3112 "SOPClassUID" : "test",
3113 "SOPInstanceUID" : "myid",
3114 },
3115 "Keep" : [ "StudyInstanceUID", "SeriesInstanceUID" ]
3116 })
3117
3118 instances = DoGet(_REMOTE, '/instances/')
3119 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/')))
3120 self.assertEqual(1, len(DoGet(_REMOTE, '/studies/')))
3121 self.assertEqual(1, len(DoGet(_REMOTE, '/series/')))
3122 self.assertEqual(2, len(instances))
3123
3124 b = instances[0] if instances[1] == a else instances[1]
3125
3126 CompareMainDicomTag('Knee (R)', a, 'study', 'StudyDescription')
3127 CompareMainDicomTag('AX. FSE PD', a, 'series', 'SeriesDescription')
3128 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID')
3129 CompareMainDicomTag('myid', b, '', 'SOPInstanceUID')
3130 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % a).strip())
3131 self.assertEqual('test', DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % b).strip())
3132
3133 DoPost(_REMOTE, '/instances/%s/reconstruct' % b, {})
3134
3135 CompareMainDicomTag('hello', a, 'study', 'StudyDescription')
3136 CompareMainDicomTag('world', a, 'series', 'SeriesDescription')
3137 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID')