# HG changeset patch # User Alain Mazy # Date 1674820278 -3600 # Node ID 2170c10f9d49eb82ed87c8fed41911fe8aa1ef9f # Parent 9f28cb3d797928088b32c21733f869bdd793f4e2 added new tests with ingest transcoding diff -r 9f28cb3d7979 -r 2170c10f9d49 NewTests/README --- a/NewTests/README Wed Jan 18 17:59:59 2023 +0100 +++ b/NewTests/README Fri Jan 27 12:51:18 2023 +0100 @@ -82,6 +82,23 @@ - interrupt and instruct you how to start your own version, pointing to the configuration file to use - execute tests +WithIngestTranscoding: +------------------ + +Runs an Orthanc with IngestTranscoding configured. + +Run theses tests with your locally build version. + +python3 NewTests/main.py --pattern=WithIngestTranscoding.* \ + --orthanc_under_tests_exe=/home/alain/o/build/orthanc/Orthanc \ + --orthanc_under_tests_http_port=8043 \ + --break_after_preparation + +The test script will: +- generate 1 configuration file in the `configurations` folder, +- interrupt and instruct you how to start your own version, pointing to the configuration file to use +- execute tests + StorageCompression: ------------------ diff -r 9f28cb3d7979 -r 2170c10f9d49 NewTests/WithIngestTranscoding/__init__.py diff -r 9f28cb3d7979 -r 2170c10f9d49 NewTests/WithIngestTranscoding/test_with_ingest_transcoding.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NewTests/WithIngestTranscoding/test_with_ingest_transcoding.py Fri Jan 27 12:51:18 2023 +0100 @@ -0,0 +1,134 @@ +import unittest +import time +import os +from helpers import OrthancTestCase, Helpers + +from orthanc_api_client import OrthancApiClient, generate_test_dicom_file +from orthanc_tools import OrthancTestDbPopulator + +import pathlib +import glob +import pprint + +here = pathlib.Path(__file__).parent.resolve() + + +class TestWithIngestTranscoding(OrthancTestCase): + + @classmethod + def prepare(cls): + print('-------------- preparing TestWithIngestTranscoding tests') + + cls.clear_storage(storage_name="WithIngestTranscoding") + + config = { + "IngestTranscoding": "1.2.840.10008.1.2.4.70" + } + + config_path = cls.generate_configuration( + config_name="with_ingest_transcoding", + storage_name="WithIngestTranscoding", + config=config, + plugins=Helpers.plugins + ) + + print('-------------- prepared TestWithIngestTranscoding tests') + if Helpers.break_after_preparation: + print(f"++++ It is now time to start your Orthanc under tests with configuration file '{config_path}' +++++") + input("Press Enter to continue") + else: + print('-------------- launching TestWithIngestTranscoding tests') + cls.launch_orthanc_under_tests( + config_path=config_path, + config_name="with_ingest_transcoding", + storage_name="WithIngestTranscoding", + plugins=Helpers.plugins + ) + + print('-------------- waiting for orthanc-under-tests to be available') + cls.o.wait_started() + + def test_modify(self): + self.o.delete_all_content() + + # upload a study + self.o.upload_file(here / "../../Database/Brainix/Flair/IM-0001-0001.dcm") + + # first modify it without transcoding + r = self.o.post( + endpoint="studies/27f7126f-4f66fb14-03f4081b-f9341db2-53925988/modify", + json={ + "Replace": {"PatientID": "TUTU"}, + "Force": True, + "KeepSource": True, + "Synchronous": True + } + ).json() + + study_id = r['ID'] + instance_id = self.o.studies.get_first_instance_id(orthanc_id=study_id) + + r = self.o.get( + endpoint=f"instances/{instance_id}/metadata?expand" + ).json() + self.assertEqual("1.2.840.10008.1.2.4.70", r['TransferSyntax']) + self.o.studies.delete(orthanc_id=study_id) + + # first modify it with transcoding -> IngestTranscoding shall not be applied + r = self.o.post( + endpoint="studies/27f7126f-4f66fb14-03f4081b-f9341db2-53925988/modify", + json={ + "Replace": {"PatientID": "TUTU"}, + "Force": True, + "KeepSource": True, + "Synchronous": True, + "Transcode": "1.2.840.10008.1.2.4.80" + } + ).json() + + instance_id = self.o.studies.get_first_instance_id(orthanc_id=r['ID']) + + r = self.o.get( + endpoint=f"instances/{instance_id}/metadata?expand" + ).json() + self.assertEqual("1.2.840.10008.1.2.4.80", r['TransferSyntax']) + + + def test_anonymize(self): + self.o.delete_all_content() + + # upload a study + self.o.upload_file(here / "../../Database/Brainix/Flair/IM-0001-0001.dcm") + + # first anonymize it without transcoding + r = self.o.post( + endpoint="studies/27f7126f-4f66fb14-03f4081b-f9341db2-53925988/anonymize", + json={ + "Synchronous": True + } + ).json() + + study_id = r['ID'] + instance_id = self.o.studies.get_first_instance_id(orthanc_id=study_id) + + r = self.o.get( + endpoint=f"instances/{instance_id}/metadata?expand" + ).json() + self.assertEqual("1.2.840.10008.1.2.4.70", r['TransferSyntax']) + self.o.studies.delete(orthanc_id=study_id) + + # first anonymize it with transcoding -> IngestTranscoding shall not be applied + r = self.o.post( + endpoint="studies/27f7126f-4f66fb14-03f4081b-f9341db2-53925988/anonymize", + json={ + "Synchronous": True, + "Transcode": "1.2.840.10008.1.2.4.80" + } + ).json() + + instance_id = self.o.studies.get_first_instance_id(orthanc_id=r['ID']) + + r = self.o.get( + endpoint=f"instances/{instance_id}/metadata?expand" + ).json() + self.assertEqual("1.2.840.10008.1.2.4.80", r['TransferSyntax'])