Mercurial > hg > orthanc-tests
diff NewTests/helpers.py @ 577:0649a19df194
new tests for auth-service
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 08 Sep 2023 12:03:50 +0200 |
parents | 80ba6f1d521c |
children | 6753d96dd71f |
line wrap: on
line diff
--- a/NewTests/helpers.py Wed Sep 06 17:04:36 2023 +0200 +++ b/NewTests/helpers.py Fri Sep 08 12:03:50 2023 +0200 @@ -82,7 +82,7 @@ def tearDownClass(cls): if not Helpers.break_after_preparation: cls.kill_orthanc() - cls._terminate() + cls.terminate() @classmethod def prepare(cls): @@ -141,6 +141,12 @@ subprocess.run(["docker", "volume", "rm", "-f", storage_name]) @classmethod + def create_docker_network(cls, network: str): + if Helpers.is_docker(): + subprocess.run(["docker", "network", "rm", network]) # ignore error + subprocess.run(["docker", "network", "create", network]) + + @classmethod def launch_orthanc_to_prepare_db(cls, config_name: str = None, config: object = None, config_path: str = None, storage_name: str = None, plugins = []): if config_name and storage_name and config: # generate the configuration file @@ -170,7 +176,7 @@ raise RuntimeError("Invalid configuration, can not launch Orthanc") @classmethod - def launch_orthanc_under_tests(cls, config_name: str = None, config: object = None, config_path: str = None, storage_name: str = None, plugins = []): + def launch_orthanc_under_tests(cls, config_name: str = None, config: object = None, config_path: str = None, storage_name: str = None, plugins = [], docker_network: str = None): if config_name and storage_name and config: # generate the configuration file config_path = cls.generate_configuration( @@ -193,7 +199,8 @@ docker_image=Helpers.orthanc_under_tests_docker_image, storage_name=storage_name, config_name=config_name, - config_path=config_path + config_path=config_path, + network=docker_network ) else: raise RuntimeError("Invalid configuration, can not launch Orthanc") @@ -214,7 +221,7 @@ raise RuntimeError(f"Orthanc failed to start '{exe_path}', conf = '{config_path}'. Check output above") @classmethod - def launch_orthanc_docker(cls, docker_image: str, storage_name: str, config_path: str, config_name: str): + def launch_orthanc_docker(cls, docker_image: str, storage_name: str, config_path: str, config_name: str, network: str = None): storage_path = cls.get_storage_path(storage_name=storage_name) cmd = [ @@ -225,9 +232,12 @@ "-v", f"{storage_path}:/var/lib/orthanc/db/", "--name", config_name, "-p", f"{Helpers.orthanc_under_tests_http_port}:{Helpers.orthanc_under_tests_http_port}", - "-p", f"{Helpers.orthanc_under_tests_dicom_port}:{Helpers.orthanc_under_tests_dicom_port}", - docker_image + "-p", f"{Helpers.orthanc_under_tests_dicom_port}:{Helpers.orthanc_under_tests_dicom_port}" ] + if network: + cmd.extend(["--network", network]) + cmd.append(docker_image) + cls._orthanc_container_name = config_name print("docker cmd line: " + " ".join(cmd))