Refactor AI daily report pipeline
This commit is contained in:
47
tests/test_cli.py
Normal file
47
tests/test_cli.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
from ai_daily_report.cli import build_parser, main
|
||||
|
||||
|
||||
class CliTests(unittest.TestCase):
|
||||
def test_run_command_parses_date_and_mode(self):
|
||||
parser = build_parser()
|
||||
|
||||
args = parser.parse_args(["run", "--date", "2026-06-04", "--mode", "dry-run", "--source-mode", "live", "--llm-mode", "live", "--sources-path", "config/sources.json"])
|
||||
|
||||
self.assertEqual(args.command, "run")
|
||||
self.assertEqual(args.date, "2026-06-04")
|
||||
self.assertEqual(args.mode, "dry-run")
|
||||
self.assertEqual(args.source_mode, "live")
|
||||
self.assertEqual(args.llm_mode, "live")
|
||||
self.assertEqual(args.sources_path, "config/sources.json")
|
||||
|
||||
def test_main_returns_zero_for_parseable_command(self):
|
||||
self.assertEqual(main(["run", "--date", "2026-06-04", "--mode", "dry-run"]), 0)
|
||||
|
||||
def test_main_mock_run_writes_outputs(self):
|
||||
with TemporaryDirectory() as temp_dir:
|
||||
exit_code = main(
|
||||
[
|
||||
"run",
|
||||
"--date",
|
||||
"2026-06-04",
|
||||
"--mode",
|
||||
"dry-run",
|
||||
"--source-mode",
|
||||
"mock",
|
||||
"--llm-mode",
|
||||
"mock",
|
||||
"--out-dir",
|
||||
temp_dir,
|
||||
]
|
||||
)
|
||||
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertTrue((Path(temp_dir) / "2026-06-04" / "blog_markdown.md").exists())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user