|
|
@ -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) |