返回 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 "StockTwits",
26 "Trustpilot",
27 "Hacker News",
28 "Polymarket",
29 "GitHub",
30 ):
31 self.assertIn(source, text, source)
32
33 def test_render_welcome_offers_scrapecreators(self):
34 text = setup_wizard.render_welcome()
35 self.assertIn("ScrapeCreators", text)
36 self.assertIn("10,000 free calls", text)
37
38 def test_welcome_command_prints_and_exits_zero(self):
39 proc = subprocess.run(
40 [sys.executable, str(ENGINE), "--welcome"],
41 capture_output=True,
42 text=True,
43 timeout=30,
44 )
45 self.assertEqual(proc.returncode, 0)
46 self.assertIn("Welcome to /last30days!", proc.stdout)
47 # The command output is exactly the engine welcome (model relays verbatim).
48 self.assertEqual(proc.stdout.strip(), setup_wizard.render_welcome().strip())
49
50
51 if __name__ == "__main__":
52 unittest.main()
53
53 lines PYTHON