Mercurial > hg > orthanc-tests
diff Tests/Tests.py @ 51:264a20a0276d
test_modify_sequence
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 09 Oct 2015 13:31:37 +0200 |
parents | 8de63d56cf11 |
children | 7c08e542db23 |
line wrap: on
line diff
--- a/Tests/Tests.py Thu Oct 08 14:52:13 2015 +0200 +++ b/Tests/Tests.py Fri Oct 09 13:31:37 2015 +0200 @@ -78,6 +78,26 @@ +def GenerateTestSequence(): + return [ + { + 'StudyDescription': 'Hello^', + 'ReferencedStudySequence' : [ + { + 'StudyDescription': 'Toto', + }, + { + 'StudyDescription': 'Tata', + }, + ] + }, + { + 'StudyDescription': 'Sébastien^', + 'StudyDate' : '19700202', + } + ] + + class Orthanc(unittest.TestCase): @@ -2315,23 +2335,7 @@ 'Tags' : { 'SpecificCharacterSet': 'ISO_IR 100', # Encode using Latin1 'PatientName': 'Jodogne^', - 'ReferencedStudySequence': [ - { - 'StudyDescription': 'Hello^', - 'ReferencedStudySequence' : [ - { - 'StudyDescription': 'Toto', - }, - { - 'StudyDescription': 'Tata', - }, - ] - }, - { - 'StudyDescription': 'Sébastien^', - 'StudyDate' : '19700202', - } - ] + 'ReferencedStudySequence': GenerateTestSequence(), } }))['ID'] @@ -2341,3 +2345,21 @@ self.assertEqual('Tata', DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/0/ReferencedStudySequence/1/StudyDescription' % i)) self.assertEqual(u'Sébastien^'.encode('latin-1'), DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/1/StudyDescription' % i)) + + + def test_modify_sequence(self): + i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] + self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence' % i)) + + j = DoPost(_REMOTE, '/instances/%s/modify' % i, + json.dumps({ + "Replace" : { + "PatientName" : "hello", + 'ReferencedStudySequence': GenerateTestSequence(), + }, + }), + 'application/json') + j = DoPost(_REMOTE, '/instances', j, 'application/dicom')['ID'] + DoDelete(_REMOTE, '/instances/%s' % i) + + self.assertEqual(2, len( DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence' % j)))