From c38c867fa3a06b4726e3f2ef25fd6f729dfd0c4b Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Wed, 6 Jul 2022 23:03:13 -0400 Subject: [PATCH] Adding an already stored path for tests --- tests/utils.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index 7feaa9f..cefe149 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -9,15 +9,26 @@ from transpose import DEFAULT_CACHE_FILENAME, version from transpose.exceptions import TransposeError -TARGET_DIR = "source" STORE_DIR = "store" +STORED_DIR = "my_app" # Directory already in storage SYMLINK_DIR = "symlink_test" +TARGET_DIR = "source" CACHE_FILE_CONTENTS = {"version": version, "original_path": TARGET_DIR} @contextmanager def setup_env(): + """ + Create the following directory structure: + temp/ + ├── source/ + │ └── .transpose.json # contains {"version": version, "original_path": "source/"} + ├── store/ + │ └── my_app/ + │ └── .transpose.json # contains {"version": version, "original_path": "source/"} + └── symlink_test/ -> source/ + """ old_dir = os.getcwd() with TemporaryDirectory("tests-temp") as td: try: @@ -25,11 +36,20 @@ def setup_env(): os.mkdir(TARGET_DIR) os.mkdir(STORE_DIR) + os.mkdir(f"{STORE_DIR}/{STORED_DIR}") os.symlink(TARGET_DIR, SYMLINK_DIR) - cache_path = pathlib.Path(TARGET_DIR).joinpath(DEFAULT_CACHE_FILENAME) - with open(str(cache_path), "w") as f: + target_cache_path1 = pathlib.Path(TARGET_DIR).joinpath( + DEFAULT_CACHE_FILENAME + ) + with open(str(target_cache_path1), "w") as f: json.dump(CACHE_FILE_CONTENTS, f) + + target_cache_path2 = pathlib.Path(f"{STORE_DIR}/{STORED_DIR}").joinpath( + DEFAULT_CACHE_FILENAME + ) + target_cache_path2.write_text(target_cache_path1.read_text()) + yield finally: os.chdir(old_dir)