comparison Plugins/DicomWeb/Run.py @ 560:2db7a9041507

test bulk data negotiation
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 28 Jun 2023 11:43:44 +0200
parents 87fc87897e7e
children a6fb40c2b722
comparison
equal deleted inserted replaced
559:87fc87897e7e 560:2db7a9041507
1763 self.assertEqual(1, len(response)) 1763 self.assertEqual(1, len(response))
1764 self.assertEqual(2, len(response[0])) 1764 self.assertEqual(2, len(response[0]))
1765 self.assertEqual('application/dicom', response[0][1]['Content-Type']) 1765 self.assertEqual('application/dicom', response[0][1]['Content-Type'])
1766 pydicom.dcmread(BytesIO(response[0][0]), force=True) 1766 pydicom.dcmread(BytesIO(response[0][0]), force=True)
1767 1767
1768 def CheckIsBulk(uri, accept):
1769 if accept != None:
1770 response = DoGetMultipart(ORTHANC, uri, headers = {
1771 'accept': accept
1772 }, returnHeaders = True)
1773 else:
1774 response = DoGetMultipart(ORTHANC, uri, returnHeaders = True)
1775 self.assertEqual(1, len(response))
1776 self.assertEqual(2, len(response[0]))
1777 self.assertEqual('application/octet-stream', response[0][1]['Content-Type'])
1778 self.assertTrue(len(response[0][0]) > 1)
1779
1768 study = UploadInstance(ORTHANC, 'ColorTestImageJ.dcm')['ParentStudy'] 1780 study = UploadInstance(ORTHANC, 'ColorTestImageJ.dcm')['ParentStudy']
1769 studyUid = DoGet(ORTHANC, '/studies/%s' % study)['MainDicomTags']['StudyInstanceUID'] 1781 studyUid = DoGet(ORTHANC, '/studies/%s' % study)['MainDicomTags']['StudyInstanceUID']
1770 1782
1771 CheckIsJson('/dicom-web/studies/%s/metadata' % studyUid, None) 1783 CheckIsJson('/dicom-web/studies/%s/metadata' % studyUid, None)
1772 CheckBadRequest('/dicom-web/studies/%s/metadata' % studyUid, 'application/nope') 1784 CheckBadRequest('/dicom-web/studies/%s/metadata' % studyUid, 'application/nope')
1787 CheckIsDicom('/dicom-web/studies/%s' % studyUid, 'multipart/related; transfer-syntax=*') 1799 CheckIsDicom('/dicom-web/studies/%s' % studyUid, 'multipart/related; transfer-syntax=*')
1788 CheckIsDicom('/dicom-web/studies/%s' % studyUid, 'multipart/related; type=application/dicom; transfer-syntax=*') 1800 CheckIsDicom('/dicom-web/studies/%s' % studyUid, 'multipart/related; type=application/dicom; transfer-syntax=*')
1789 CheckBadRequest('/dicom-web/studies/%s' % studyUid, 'multipart/related; transfer-syntax=nope') 1801 CheckBadRequest('/dicom-web/studies/%s' % studyUid, 'multipart/related; transfer-syntax=nope')
1790 CheckIsDicom('/dicom-web/studies/%s' % studyUid, 'multipart/related; type=application/dicom; transfer-syntax=1.2.840.10008.1.2.1') 1802 CheckIsDicom('/dicom-web/studies/%s' % studyUid, 'multipart/related; type=application/dicom; transfer-syntax=1.2.840.10008.1.2.1')
1791 1803
1804 uri = '/dicom-web/studies/%s/series/%s/instances/%s/bulk/0010,0010' % (
1805 studyUid, '1.3.12.2.1107.5.99.2.1255.30000007020811545343700000012',
1806 '1.2.276.0.7230010.3.1.4.2455711835.6056.1170936079.1')
1807 CheckIsBulk(uri, None)
1808 CheckBadRequest(uri, 'multipart/nope')
1809 CheckIsBulk(uri, 'multipart/related')
1810 CheckIsBulk(uri, 'multipart/related;type=application/octet-stream')
1811 CheckIsBulk(uri, 'multipart/related; type = "application/octet-stream" ')
1812 CheckBadRequest(uri, 'multipart/related; type = " application/octet-stream" ')
1813 CheckBadRequest(uri, 'multipart/related;type=application/nope')
1814 CheckBadRequest(uri, 'multipart/related;range=')
1815
1792 1816
1793 try: 1817 try:
1794 print('\nStarting the tests...') 1818 print('\nStarting the tests...')
1795 unittest.main(argv = [ sys.argv[0] ] + args.options) 1819 unittest.main(argv = [ sys.argv[0] ] + args.options)
1796 1820