refactor: simplify runtime, config, and telegram (#85)

This commit is contained in:
banteg
2026-01-11 14:48:39 +04:00
committed by GitHub
parent 2380b3e5e9
commit 194cc02bba
42 changed files with 3204 additions and 3717 deletions
+10 -11
View File
@@ -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)