返回 last30days-skill
test_welcome.py
根目录 / tests / test_welcome.py
1 """U1: the first-run welcome is engine-owned so the model relays it (rather than
2 authoring prose it reliably skips) and it cannot drift from the source set."""
3
4 import subprocess
5 import sys
6 import unittest
7 from pathlib import Path
8
9 from lib import setup_wizard
10
11 ROOT = Path(__file__).resolve().parents[1]
12 ENGINE = ROOT / "skills" / "last30days" / "scripts" / "last30days.py"
13
14
15 class TestWelcome(unittest.TestCase):
16 def test_render_welcome_names_the_source_set(self):
17 text = setup_wizard.render_welcome()
18 for source in (
19 "X/Twitter",
20 "Reddit",
21 "YouTube",
22 "Digg",
23 "arXiv",
24 "Techmeme",
25 "News RSS",
26 "Yahoo Finance",
27 "StockTwits",
28 "Trustpilot",
29 "Hacker News",
30 "Polymarket",
31 "GitHub",
32 ):
33 self.assertIn(source, text, source)
34
35 def test_render_welcome_offers_scrapecreators(self):
36 text = setup_wizard.render_welcome()
37 self.assertIn("ScrapeCreators", text)
38 self.assertIn("10,000 free calls", text)
39
40 def test_welcome_command_prints_and_exits_zero(self):
41 proc = subprocess.run(
42 [sys.executable, str(ENGINE), "--welcome"],
43 capture_output=True,
44 text=True,
45 timeout=30,
46 )
47 self.assertEqual(proc.returncode, 0)
48 self.assertIn("Welcome to /last30days!", proc.stdout)
49 # The command output is exactly the engine welcome (model relays verbatim).
50 self.assertEqual(proc.stdout.strip(), setup_wizard.render_welcome().strip())
51
52
53 if __name__ == "__main__":
54 unittest.main()
55
55 lines PYTHON