返回 last30days-skill
test_vs_mode_fanout.py
根目录 / tests / test_vs_mode_fanout.py
1 """Tests for vs-mode routing into the competitor fanout.
2
3 A topic containing " vs " / " versus " triggers N-pass fanout (not the
4 old single-pipeline comparison plan). Each entity gets its own full
5 pipeline.run() with its own Step 0.55 targeting.
6 """
7
8 from __future__ import annotations
9
10 import io
11 import unittest
12 from contextlib import redirect_stderr
13
14 from lib import planner
15
16
17 class VsModeEntityDetectionTests(unittest.TestCase):
18 """The planner's _comparison_entities helper is the detector we use."""
19
20 def test_two_entity_vs(self):
21 self.assertEqual(
22 planner._comparison_entities("OpenAI vs Anthropic"),
23 ["OpenAI", "Anthropic"],
24 )
25
26 def test_three_entity_vs(self):
27 self.assertEqual(
28 planner._comparison_entities("Kanye West vs Drake vs Kendrick Lamar"),
29 ["Kanye West", "Drake", "Kendrick Lamar"],
30 )
31
32 def test_versus_alt_spelling(self):
33 result = planner._comparison_entities("A versus B")
34 self.assertEqual(result, ["A", "B"])
35
36 def test_dotted_vs(self):
37 result = planner._comparison_entities("A vs. B")
38 self.assertEqual(result, ["A", "B"])
39
40 def test_no_vs_returns_empty(self):
41 self.assertEqual(planner._comparison_entities("OpenAI"), [])
42
43 def test_trailing_vs_returns_empty_or_single(self):
44 # "OpenAI vs" with nothing after — should not trigger vs-mode
45 result = planner._comparison_entities("OpenAI vs")
46 # _comparison_entities caps at _max_subqueries("comparison") and
47 # requires >=2 parts. Single "OpenAI" with empty after vs -> []
48 self.assertLess(len(result), 2)
49
50 def test_dedup_identical_entities(self):
51 # Defense against silly input — two "Drake"s should collapse.
52 result = planner._comparison_entities("Drake vs Drake")
53 self.assertEqual(result, ["Drake"])
54
55 if __name__ == "__main__":
56 unittest.main()
57
57 lines PYTHON