# HG changeset patch # User Alain Mazy # Date 1748356189 -7200 # Node ID cc4f3fbcd0750cbc32dec4cb60316bcf33e1164e # Parent ae32a816cbe46929a73687289001f805d9ca02b0 fix storage tests diff -r ae32a816cbe4 -r cc4f3fbcd075 NewTests/AdvancedStorage/test_advanced_storage.py --- 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, diff -r ae32a816cbe4 -r cc4f3fbcd075 NewTests/helpers.py --- 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)