Mercurial > hg > orthanc-tests
changeset 821:cc4f3fbcd075 attach-custom-data
fix storage tests
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Tue, 27 May 2025 16:29:49 +0200 |
| parents | ae32a816cbe4 |
| children | f094845ac9a2 |
| files | NewTests/AdvancedStorage/test_advanced_storage.py NewTests/helpers.py |
| diffstat | 2 files changed, 21 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/NewTests/AdvancedStorage/test_advanced_storage.py Tue May 27 16:20:18 2025 +0200 +++ b/NewTests/AdvancedStorage/test_advanced_storage.py Tue May 27 16:29:49 2025 +0200 @@ -62,6 +62,24 @@ cls.clear_storage(storage_name=cls._storage_name) + # the path seen by the test + cls.base_test_storage_path = cls.get_storage_path(storage_name=cls._storage_name) + '/' + + # the path seen by orthanc + if Helpers.is_docker(): + cls.base_orthanc_storage_path = "/var/lib/orthanc/db/" + else: + cls.base_orthanc_storage_path = cls.base_test_storage_path + + shutil.rmtree(cls.base_test_storage_path + 'indexed-files-a', ignore_errors=True) + shutil.rmtree(cls.base_test_storage_path + 'indexed-files-b', ignore_errors=True) + shutil.rmtree(cls.base_test_storage_path + 'adopt-files', ignore_errors=True) + + pathlib.Path(cls.base_test_storage_path + 'indexed-files-a').mkdir(parents=True, exist_ok=True) + pathlib.Path(cls.base_test_storage_path + 'indexed-files-b').mkdir(parents=True, exist_ok=True) + pathlib.Path(cls.base_test_storage_path + 'adopt-files').mkdir(parents=True, exist_ok=True) + + print(f'-------------- preparing {test_name} tests') if Helpers.is_docker(): @@ -116,23 +134,6 @@ cls.kill_orthanc() time.sleep(3) - # the path seen by the test - cls.base_test_storage_path = cls.get_storage_path(storage_name=cls._storage_name) + '/' - - # the path seen by orthanc - if Helpers.is_docker(): - cls.base_orthanc_storage_path = "/var/lib/orthanc/db/" - else: - cls.base_orthanc_storage_path = cls.base_test_storage_path - - shutil.rmtree(cls.base_test_storage_path + 'indexed-files-a', ignore_errors=True) - shutil.rmtree(cls.base_test_storage_path + 'indexed-files-b', ignore_errors=True) - shutil.rmtree(cls.base_test_storage_path + 'adopt-files', ignore_errors=True) - - pathlib.Path(cls.base_test_storage_path + 'indexed-files-a').mkdir(parents=True, exist_ok=True) - pathlib.Path(cls.base_test_storage_path + 'indexed-files-b').mkdir(parents=True, exist_ok=True) - pathlib.Path(cls.base_test_storage_path + 'adopt-files').mkdir(parents=True, exist_ok=True) - config = { db_config_key : db_config_content, "AuthenticationEnabled": False,
--- a/NewTests/helpers.py Tue May 27 16:20:18 2025 +0200 +++ b/NewTests/helpers.py Tue May 27 16:29:49 2025 +0200 @@ -185,6 +185,7 @@ # shutil.rmtree(os.path.join(root, d)) # shutil.rmtree(storage_path, ignore_errors=True) else: + # clear the directory (but you need to be root from the container !) cmd = [ "docker", "run", "--rm", "-v", f"{storage_path}:/var/lib/orthanc/db/", @@ -193,7 +194,8 @@ "bash", "-c", "rm -rf /var/lib/orthanc/db/*" ] subprocess.run(cmd, check=True) - + + # create the directory with user ownership pathlib.Path(storage_path).mkdir(parents=True, exist_ok=True)
