Mercurial > hg > orthanc-tests
comparison Tests/Tests.py @ 328:8a462f9c5a97
test_store_compressed
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 23 Aug 2020 12:05:07 +0200 |
parents | 33ba5b1a0dd9 |
children | dc41bfa4bda5 |
comparison
equal
deleted
inserted
replaced
327:33ba5b1a0dd9 | 328:8a462f9c5a97 |
---|---|
5861 # studies (i.e. 2). This issue was fixed in Orthanc 1.7.3. | 5861 # studies (i.e. 2). This issue was fixed in Orthanc 1.7.3. |
5862 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', | 5862 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', |
5863 'StudyInstanceUID=%s\\%s\\%s\\%s\\%s\\%s' % (( study, ) * 6) ]) | 5863 'StudyInstanceUID=%s\\%s\\%s\\%s\\%s\\%s' % (( study, ) * 6) ]) |
5864 result = re.findall('\(0020,000d\).*?\[(.*?)\]', i) | 5864 result = re.findall('\(0020,000d\).*?\[(.*?)\]', i) |
5865 self.assertEqual(1, len(result)) | 5865 self.assertEqual(1, len(result)) |
5866 | 5866 |
5867 | |
5868 def test_store_compressed(self): | |
5869 with open(GetDatabasePath('DummyCT.dcm'), 'rb') as f: | |
5870 dicom = f.read() | |
5871 i = DoPost(_REMOTE, '/instances', dicom) ['ID'] | |
5872 sourceSize = len(dicom) | |
5873 | |
5874 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
5875 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
5876 | |
5877 # Sending to the local Orthanc 0.8.6 server, without compression: OK | |
5878 jobId = MonitorJob2(_REMOTE, lambda: DoPost( | |
5879 _REMOTE, '/peers/peer/store', { | |
5880 'Resources' : [ i ], | |
5881 'Synchronous' : False, | |
5882 })) | |
5883 | |
5884 job = DoGet(_REMOTE, '/jobs/%s' % jobId) | |
5885 self.assertFalse(job['Content']['Compress']) | |
5886 self.assertEqual('', job['Content']['Peer'][2]) # Password must not be reported | |
5887 self.assertEqual(str(sourceSize), job['Content']['Size']) | |
5888 | |
5889 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
5890 DropOrthanc(_LOCAL) | |
5891 | |
5892 # Sending to the local Orthanc 0.8.6 server, with compression: | |
5893 # Not supported by Orthanc 0.8.6 => failure | |
5894 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/peers/peer/store', { | |
5895 'Resources' : [ i ], | |
5896 'Compress' : True, | |
5897 })) | |
5898 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
5899 | |
5900 # Sending to the tested remote server, with compression: OK | |
5901 jobId = MonitorJob2(_REMOTE, lambda: DoPost( | |
5902 _REMOTE, '/peers/self/store', { | |
5903 'Resources' : [ i ], | |
5904 'Compress' : True, | |
5905 'Synchronous' : False, | |
5906 })) | |
5907 | |
5908 job = DoGet(_REMOTE, '/jobs/%s' % jobId) | |
5909 self.assertTrue(job['Content']['Compress']) | |
5910 | |
5911 # Compression must have divided the size of the sent data at least twice | |
5912 self.assertLess(int(job['Content']['Size']), sourceSize / 2) |