diff --git a/pyproject.toml b/pyproject.toml index 61cf854..0fc2491 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "transpose" -version = "2.2.1" +version = "2.2.2" description = "Move and symlink a path to a central location" authors = ["Ryan Reed"] license = "GPLv3" diff --git a/src/transpose/transpose.py b/src/transpose/transpose.py index ca82e12..0f7ec99 100644 --- a/src/transpose/transpose.py +++ b/src/transpose/transpose.py @@ -135,6 +135,8 @@ class TransposeConfig: in_config = json.load(open(config_path, "r")) except json.decoder.JSONDecodeError as e: raise TransposeError(f"Invalid JSON format for '{config_path}': {e}") + except FileNotFoundError: + in_config = {"entries": {}} config = TransposeConfig() try: diff --git a/tests/test_transpose.py b/tests/test_transpose.py index 758f181..321e7b9 100644 --- a/tests/test_transpose.py +++ b/tests/test_transpose.py @@ -216,6 +216,22 @@ def test_config_save(): ) +@setup_store() +def test_config_save_fresh(): + """ + Verify creation of transpose config when doesn't initially exist + """ + TRANSPOSE_CONFIG_PATH.unlink() + config = TransposeConfig.load(TRANSPOSE_CONFIG_PATH) + assert len(config.entries) == 0 + + config.add("TestEntry", TARGET_PATH) + config.save(TRANSPOSE_CONFIG_PATH) + + config = TransposeConfig.load(TRANSPOSE_CONFIG_PATH) + assert config.entries.get("TestEntry") + + @setup_store() def test_config_load(): config = TransposeConfig.load(TRANSPOSE_CONFIG_PATH)