diff options
| author | Danilo M. <danix@danix.xyz> | 2026-05-01 12:42:29 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-05-01 12:42:29 +0200 |
| commit | 5d59ab205cb00e1dc2abd242ccf93a7006c7b18f (patch) | |
| tree | be16f7fb960175ce5101da7f8b0445ef482f3000 /tests/test_config.py | |
| parent | a6e441f6e1934313bb47b5391d3217a05d13b992 (diff) | |
| download | publisher-5d59ab205cb00e1dc2abd242ccf93a7006c7b18f.tar.gz publisher-5d59ab205cb00e1dc2abd242ccf93a7006c7b18f.zip | |
feat: config load/save with tomlkit
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_config.py')
| -rw-r--r-- | tests/test_config.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_config.py b/tests/test_config.py new file mode 100644 index 0000000..6b3417f --- /dev/null +++ b/tests/test_config.py @@ -0,0 +1,29 @@ +import pytest +from pathlib import Path +import tempfile, os +from core.config import Config, DEFAULT_CONFIG_PATH + +def test_config_loads_defaults_when_missing(tmp_path, monkeypatch): + monkeypatch.setattr("core.config.DEFAULT_CONFIG_PATH", tmp_path / "config.toml") + cfg = Config.load() + assert cfg.blog_repo == "" + assert cfg.transart_script == "/home/danix/bin/transart.py" + assert cfg.typora_bin == "typora" + +def test_config_round_trips(tmp_path, monkeypatch): + path = tmp_path / "config.toml" + monkeypatch.setattr("core.config.DEFAULT_CONFIG_PATH", path) + cfg = Config(blog_repo="/some/path", transart_script="/bin/x", typora_bin="typora") + cfg.save() + loaded = Config.load() + assert loaded.blog_repo == "/some/path" + +def test_config_is_complete_false_when_blog_repo_empty(tmp_path, monkeypatch): + monkeypatch.setattr("core.config.DEFAULT_CONFIG_PATH", tmp_path / "config.toml") + cfg = Config.load() + assert cfg.is_complete() is False + +def test_config_is_complete_true_when_all_set(tmp_path, monkeypatch): + monkeypatch.setattr("core.config.DEFAULT_CONFIG_PATH", tmp_path / "config.toml") + cfg = Config(blog_repo="/some/repo", transart_script="/bin/x", typora_bin="typora") + assert cfg.is_complete() is True |
