Mercurial > hg > orthanc-tests
comparison Plugins/DicomWeb/Run.py @ 562:a6fb40c2b722
merge
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 28 Jun 2023 16:44:21 +0200 |
parents | 2c809c605592 2db7a9041507 |
children | be69d6d8260c |
comparison
equal
deleted
inserted
replaced
561:2c809c605592 | 562:a6fb40c2b722 |
---|---|
35 | 35 |
36 import argparse | 36 import argparse |
37 import copy | 37 import copy |
38 import os | 38 import os |
39 import pprint | 39 import pprint |
40 import pydicom | |
40 import re | 41 import re |
41 import sys | 42 import sys |
42 import unittest | 43 import unittest |
43 import xml.dom.minidom | 44 import xml.dom.minidom |
44 from PIL import ImageChops | 45 from PIL import ImageChops |
1751 self.assertEqual(1, len(response)) | 1752 self.assertEqual(1, len(response)) |
1752 self.assertEqual(2, len(response[0])) | 1753 self.assertEqual(2, len(response[0])) |
1753 self.assertEqual('application/dicom+xml', response[0][1]['Content-Type']) | 1754 self.assertEqual('application/dicom+xml', response[0][1]['Content-Type']) |
1754 xml.dom.minidom.parseString(response[0][0]) | 1755 xml.dom.minidom.parseString(response[0][0]) |
1755 | 1756 |
1757 def CheckIsDicom(uri, accept): | |
1758 if accept != None: | |
1759 response = DoGetMultipart(ORTHANC, uri, headers = { | |
1760 'accept': accept | |
1761 }, returnHeaders = True) | |
1762 else: | |
1763 response = DoGetMultipart(ORTHANC, uri, returnHeaders = True) | |
1764 self.assertEqual(1, len(response)) | |
1765 self.assertEqual(2, len(response[0])) | |
1766 self.assertEqual('application/dicom', response[0][1]['Content-Type']) | |
1767 pydicom.dcmread(BytesIO(response[0][0]), force=True) | |
1768 | |
1769 def CheckIsBulk(uri, accept): | |
1770 if accept != None: | |
1771 response = DoGetMultipart(ORTHANC, uri, headers = { | |
1772 'accept': accept | |
1773 }, returnHeaders = True) | |
1774 else: | |
1775 response = DoGetMultipart(ORTHANC, uri, returnHeaders = True) | |
1776 self.assertEqual(1, len(response)) | |
1777 self.assertEqual(2, len(response[0])) | |
1778 self.assertEqual('application/octet-stream', response[0][1]['Content-Type']) | |
1779 self.assertTrue(len(response[0][0]) > 1) | |
1780 | |
1756 study = UploadInstance(ORTHANC, 'ColorTestImageJ.dcm')['ParentStudy'] | 1781 study = UploadInstance(ORTHANC, 'ColorTestImageJ.dcm')['ParentStudy'] |
1757 studyUid = DoGet(ORTHANC, '/studies/%s' % study)['MainDicomTags']['StudyInstanceUID'] | 1782 studyUid = DoGet(ORTHANC, '/studies/%s' % study)['MainDicomTags']['StudyInstanceUID'] |
1758 | 1783 |
1759 CheckIsJson('/dicom-web/studies/%s/metadata' % studyUid, None) | 1784 CheckIsJson('/dicom-web/studies/%s/metadata' % studyUid, None) |
1760 CheckBadRequest('/dicom-web/studies/%s/metadata' % studyUid, 'application/nope') | 1785 CheckBadRequest('/dicom-web/studies/%s/metadata' % studyUid, 'application/nope') |
1764 CheckIsXml('/dicom-web/studies/%s/metadata' % studyUid, 'multipart/related; type=application/dicom+xml') | 1789 CheckIsXml('/dicom-web/studies/%s/metadata' % studyUid, 'multipart/related; type=application/dicom+xml') |
1765 CheckIsXml('/dicom-web/studies/%s/metadata' % studyUid, 'multipart/related; type="application/dicom+xml"') | 1790 CheckIsXml('/dicom-web/studies/%s/metadata' % studyUid, 'multipart/related; type="application/dicom+xml"') |
1766 CheckBadRequest('/dicom-web/studies/%s/metadata' % studyUid, 'multipart/related; type="application/nope"') | 1791 CheckBadRequest('/dicom-web/studies/%s/metadata' % studyUid, 'multipart/related; type="application/nope"') |
1767 CheckBadRequest('/dicom-web/studies/%s/metadata' % studyUid, 'multipart/related; type=application/dicom+xml; transfer-syntax=nope') | 1792 CheckBadRequest('/dicom-web/studies/%s/metadata' % studyUid, 'multipart/related; type=application/dicom+xml; transfer-syntax=nope') |
1768 | 1793 |
1794 CheckBadRequest('/dicom-web/studies/%s' % studyUid, 'multipart/nope') | |
1795 CheckIsDicom('/dicom-web/studies/%s' % studyUid, None) | |
1796 CheckIsDicom('/dicom-web/studies/%s' % studyUid, 'multipart/related') | |
1797 CheckIsDicom('/dicom-web/studies/%s' % studyUid, 'multipart/related; type=application/dicom') | |
1798 CheckIsDicom('/dicom-web/studies/%s' % studyUid, 'multipart/related; type="application/dicom"') | |
1799 CheckBadRequest('/dicom-web/studies/%s' % studyUid, 'multipart/related; type=application/nope') | |
1800 CheckIsDicom('/dicom-web/studies/%s' % studyUid, 'multipart/related; transfer-syntax=*') | |
1801 CheckIsDicom('/dicom-web/studies/%s' % studyUid, 'multipart/related; type=application/dicom; transfer-syntax=*') | |
1802 CheckBadRequest('/dicom-web/studies/%s' % studyUid, 'multipart/related; transfer-syntax=nope') | |
1803 CheckIsDicom('/dicom-web/studies/%s' % studyUid, 'multipart/related; type=application/dicom; transfer-syntax=1.2.840.10008.1.2.1') | |
1804 | |
1805 uri = '/dicom-web/studies/%s/series/%s/instances/%s/bulk/0010,0010' % ( | |
1806 studyUid, '1.3.12.2.1107.5.99.2.1255.30000007020811545343700000012', | |
1807 '1.2.276.0.7230010.3.1.4.2455711835.6056.1170936079.1') | |
1808 CheckIsBulk(uri, None) | |
1809 CheckBadRequest(uri, 'multipart/nope') | |
1810 CheckIsBulk(uri, 'multipart/related') | |
1811 CheckIsBulk(uri, 'multipart/related;type=application/octet-stream') | |
1812 CheckIsBulk(uri, 'multipart/related; type = "application/octet-stream" ') | |
1813 CheckBadRequest(uri, 'multipart/related; type = " application/octet-stream" ') | |
1814 CheckBadRequest(uri, 'multipart/related;type=application/nope') | |
1815 CheckBadRequest(uri, 'multipart/related;range=') | |
1816 | |
1769 | 1817 |
1770 try: | 1818 try: |
1771 print('\nStarting the tests...') | 1819 print('\nStarting the tests...') |
1772 unittest.main(argv = [ sys.argv[0] ] + args.options) | 1820 unittest.main(argv = [ sys.argv[0] ] + args.options) |
1773 | 1821 |