diff Tests/Tests.py @ 47:f610491f74c3

test_create_binary
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 23 Sep 2015 12:43:20 +0200
parents 85b2e36ed392
children e4352463ff74
line wrap: on
line diff
--- a/Tests/Tests.py	Wed Sep 23 12:04:57 2015 +0200
+++ b/Tests/Tests.py	Wed Sep 23 12:43:20 2015 +0200
@@ -2216,3 +2216,29 @@
         patient = DoGet(_REMOTE, '/instances/%s/patient' % s['Instances'][0])
         self.assertEqual(patient['MainDicomTags']['PatientName'].encode('utf-8'),
                          'Sébastien Jodogne')
+
+
+    def test_create_binary(self):
+        binary = ''.join(map(chr, range(256)))
+        encoded = 'data:application/octet-stream;base64,' + base64.b64encode(binary)
+        tags = {
+            'PatientName' : 'Jodogne',
+            '8899-8899' : encoded
+        }
+
+        i = DoPost(_REMOTE, '/tools/create-dicom',
+                   json.dumps({
+                       'Tags' : tags
+                   }))
+
+        self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip())
+        self.assertEqual(binary, DoGet(_REMOTE, '/instances/%s/content/8899-8899' % i['ID']).strip())
+
+        i = DoPost(_REMOTE, '/tools/create-dicom',
+                   json.dumps({
+                       'InterpretBinaryTags' : False,
+                       'Tags' : tags
+                   }))
+
+        self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip())
+        self.assertEqual(encoded, DoGet(_REMOTE, '/instances/%s/content/8899-8899' % i['ID'])[0:-1])