refactor: simplify runtime, config, and telegram (#85)
This commit is contained in:
+10
-11
@@ -4,38 +4,37 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from takopi.config import ConfigError
|
||||
from takopi.config_store import read_raw_toml, write_raw_toml
|
||||
from takopi.config import ConfigError, read_config, write_config
|
||||
|
||||
|
||||
def test_read_write_raw_toml_round_trip(tmp_path: Path) -> None:
|
||||
def test_read_write_config_round_trip(tmp_path: Path) -> None:
|
||||
config_path = tmp_path / "takopi.toml"
|
||||
payload = {
|
||||
"default_engine": "codex",
|
||||
"projects": {"z80": {"path": "/tmp/repo"}},
|
||||
}
|
||||
|
||||
write_raw_toml(payload, config_path)
|
||||
loaded = read_raw_toml(config_path)
|
||||
write_config(payload, config_path)
|
||||
loaded = read_config(config_path)
|
||||
|
||||
assert loaded == payload
|
||||
|
||||
|
||||
def test_read_raw_toml_missing_file(tmp_path: Path) -> None:
|
||||
def test_read_config_missing_file(tmp_path: Path) -> None:
|
||||
config_path = tmp_path / "missing.toml"
|
||||
with pytest.raises(ConfigError, match="Missing config file"):
|
||||
read_raw_toml(config_path)
|
||||
read_config(config_path)
|
||||
|
||||
|
||||
def test_read_raw_toml_invalid_toml(tmp_path: Path) -> None:
|
||||
def test_read_config_invalid_toml(tmp_path: Path) -> None:
|
||||
config_path = tmp_path / "takopi.toml"
|
||||
config_path.write_text("nope = [", encoding="utf-8")
|
||||
with pytest.raises(ConfigError, match="Malformed TOML"):
|
||||
read_raw_toml(config_path)
|
||||
read_config(config_path)
|
||||
|
||||
|
||||
def test_read_raw_toml_non_file(tmp_path: Path) -> None:
|
||||
def test_read_config_non_file(tmp_path: Path) -> None:
|
||||
config_path = tmp_path / "config_dir"
|
||||
config_path.mkdir()
|
||||
with pytest.raises(ConfigError, match="exists but is not a file"):
|
||||
read_raw_toml(config_path)
|
||||
read_config(config_path)
|
||||
|
||||
Reference in New Issue
Block a user