Browse Source

Fix: Loading transpose config when none exists

master v2.2.2
Ryan Reed 1 year ago
parent
commit
4039656986
3 changed files with 19 additions and 1 deletions
  1. +1
    -1
      pyproject.toml
  2. +2
    -0
      src/transpose/transpose.py
  3. +16
    -0
      tests/test_transpose.py

+ 1
- 1
pyproject.toml View File

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


+ 2
- 0
src/transpose/transpose.py View File

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


+ 16
- 0
tests/test_transpose.py View File

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


Loading…
Cancel
Save