test+ci: add regression tests and GitHub Actions workflow

This commit is contained in:
jackwener
2026-03-05 16:14:05 +08:00
parent 4c08d09304
commit 6f322ff2d6
7 changed files with 225 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
from __future__ import annotations
from pathlib import Path
from twitter_cli.config import load_config
def test_filter_normalization_for_invalid_values(tmp_path: Path) -> None:
config_file = tmp_path / "config.yaml"
config_file.write_text(
"\n".join(
[
"fetch:",
" count: -5",
"filter:",
" mode: unknown",
" topN: -1",
" minScore: abc",
" lang: zh",
" weights:",
" likes: bad",
" retweets: 4",
]
),
encoding="utf-8",
)
config = load_config(str(config_file))
assert config["fetch"]["count"] == 1
assert config["filter"]["mode"] == "topN"
assert config["filter"]["topN"] == 1
assert config["filter"]["minScore"] == 50.0
assert config["filter"]["lang"] == []
assert config["filter"]["weights"]["likes"] == 1.0
assert config["filter"]["weights"]["retweets"] == 4.0