# HG changeset patch # User Alain Mazy # Date 1733471826 -3600 # Node ID 27a955d3d05f97e32852b093fcaf61f00eddfd24 # Parent 09d3e251b783845fee2caa36d40702069e0c3804 fix tests version diff -r 09d3e251b783 -r 27a955d3d05f Tests/Tests.py --- a/Tests/Tests.py Wed Dec 04 18:14:01 2024 +0100 +++ b/Tests/Tests.py Fri Dec 06 08:57:06 2024 +0100 @@ -10839,50 +10839,51 @@ self.assertEqual('application/octet-stream', resp['content-type']) self.assertEqual('bytes 0-131/2472', resp['content-range']) - i = UploadInstance(_REMOTE, 'DummyCT.dcm') ['ID'] - - DoPost(_REMOTE, '/instances/%s/attachments/dicom/uncompress' % i) - TestData('data') - TestData('compressed-data') - - DoPost(_REMOTE, '/instances/%s/attachments/dicom/compress' % i) - TestData('data') - - (resp, compressed) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i) - self.assertFalse('content-range' in resp) - self.assertEqual(200, resp.status) - self.assertTrue(len(compressed) < 2000) - self.assertEqual(len(compressed), int(resp['content-length'])) - self.assertEqual('application/octet-stream', resp['content-type']) - - (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i, headers = { 'Range' : 'bytes=-' }) - self.assertTrue('content-range' in resp) - self.assertEqual(206, resp.status) - self.assertEqual(compressed, content) - self.assertEqual(len(compressed), int(resp['content-length'])) - self.assertEqual('application/octet-stream', resp['content-type']) - self.assertEqual('bytes 0-%d/%d' % (len(compressed) - 1, len(compressed)), resp['content-range']) - - (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i, headers = { 'Range' : 'bytes=10-' }) - self.assertTrue('content-range' in resp) - self.assertEqual(206, resp.status) - self.assertEqual(compressed[10:], content) - self.assertEqual(len(compressed) - 10, int(resp['content-length'])) - self.assertEqual('application/octet-stream', resp['content-type']) - self.assertEqual('bytes 10-%d/%d' % (len(compressed) - 1, len(compressed)), resp['content-range']) - - (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i, headers = { 'Range' : 'bytes=-20' }) - self.assertTrue('content-range' in resp) - self.assertEqual(206, resp.status) - self.assertEqual(compressed[0:21], content) - self.assertEqual(21, int(resp['content-length'])) - self.assertEqual('application/octet-stream', resp['content-type']) - self.assertEqual('bytes 0-20/%d' % len(compressed), resp['content-range']) - - (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i, headers = { 'Range' : 'bytes=10-20' }) - self.assertTrue('content-range' in resp) - self.assertEqual(206, resp.status) - self.assertEqual(compressed[10:21], content) - self.assertEqual(11, int(resp['content-length'])) - self.assertEqual('application/octet-stream', resp['content-type']) - self.assertEqual('bytes 10-20/%d' % len(compressed), resp['content-range']) + if IsOrthancVersionAbove(_REMOTE, 1, 12, 5): + i = UploadInstance(_REMOTE, 'DummyCT.dcm') ['ID'] + + DoPost(_REMOTE, '/instances/%s/attachments/dicom/uncompress' % i) + TestData('data') + TestData('compressed-data') + + DoPost(_REMOTE, '/instances/%s/attachments/dicom/compress' % i) + TestData('data') + + (resp, compressed) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i) + self.assertFalse('content-range' in resp) + self.assertEqual(200, resp.status) + self.assertTrue(len(compressed) < 2000) + self.assertEqual(len(compressed), int(resp['content-length'])) + self.assertEqual('application/octet-stream', resp['content-type']) + + (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i, headers = { 'Range' : 'bytes=-' }) + self.assertTrue('content-range' in resp) + self.assertEqual(206, resp.status) + self.assertEqual(compressed, content) + self.assertEqual(len(compressed), int(resp['content-length'])) + self.assertEqual('application/octet-stream', resp['content-type']) + self.assertEqual('bytes 0-%d/%d' % (len(compressed) - 1, len(compressed)), resp['content-range']) + + (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i, headers = { 'Range' : 'bytes=10-' }) + self.assertTrue('content-range' in resp) + self.assertEqual(206, resp.status) + self.assertEqual(compressed[10:], content) + self.assertEqual(len(compressed) - 10, int(resp['content-length'])) + self.assertEqual('application/octet-stream', resp['content-type']) + self.assertEqual('bytes 10-%d/%d' % (len(compressed) - 1, len(compressed)), resp['content-range']) + + (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i, headers = { 'Range' : 'bytes=-20' }) + self.assertTrue('content-range' in resp) + self.assertEqual(206, resp.status) + self.assertEqual(compressed[0:21], content) + self.assertEqual(21, int(resp['content-length'])) + self.assertEqual('application/octet-stream', resp['content-type']) + self.assertEqual('bytes 0-20/%d' % len(compressed), resp['content-range']) + + (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i, headers = { 'Range' : 'bytes=10-20' }) + self.assertTrue('content-range' in resp) + self.assertEqual(206, resp.status) + self.assertEqual(compressed[10:21], content) + self.assertEqual(11, int(resp['content-length'])) + self.assertEqual('application/octet-stream', resp['content-type']) + self.assertEqual('bytes 10-20/%d' % len(compressed), resp['content-range'])