返回 last30days-skill
test_render_hiring_signals.py
根目录 / tests / test_render_hiring_signals.py
1 import unittest
2
3 from lib import render, schema
4
5
6 class RenderHiringSignalsTests(unittest.TestCase):
7 def test_render_hiring_signals_block_with_citations(self):
8 report = schema.Report(
9 topic="Listen Labs",
10 range_from="2026-05-16",
11 range_to="2026-06-16",
12 generated_at="2026-06-16T00:00:00Z",
13 provider_runtime=schema.ProviderRuntime("mock", "mock", "mock"),
14 query_plan=schema.QueryPlan(
15 intent="product",
16 freshness_mode="balanced_recent",
17 cluster_mode="none",
18 raw_topic="Listen Labs",
19 subqueries=[],
20 source_weights={},
21 ),
22 clusters=[],
23 ranked_candidates=[],
24 items_by_source={},
25 errors_by_source={},
26 artifacts={
27 "hiring_signals": {
28 "mode": "standard",
29 "company_size_tier": "startup",
30 "include": True,
31 "signals": [
32 {
33 "theme": "enterprise readiness",
34 "interpretation": "appears to be increasing focus on enterprise readiness",
35 "confidence": "medium",
36 "evidence_count": 2,
37 "evidence": [
38 {
39 "title": "Enterprise Security Engineer",
40 "url": "https://example.com/jobs/1",
41 "department": "Engineering",
42 "published_at": "2026-06-01",
43 }
44 ],
45 }
46 ],
47 }
48 },
49 )
50 block = "\n".join(render._render_hiring_signals(report))
51 self.assertIn("Hiring Signals", block)
52 self.assertIn("[Enterprise Security Engineer](https://example.com/jobs/1)", block)
53 self.assertIn("not exact roadmap predictions", block)
54 html_md = render.render_for_html(report)
55 self.assertIn("Hiring Signals", html_md)
56 self.assertIn("[Enterprise Security Engineer](https://example.com/jobs/1)", html_md)
57 synthesized_html_md = render.render_for_html(
58 report,
59 synthesis_md="What I learned:\n\nHiring points toward enterprise readiness.",
60 )
61 self.assertIn("What I learned", synthesized_html_md)
62 self.assertIn("Hiring Signals", synthesized_html_md)
63 self.assertIn("[Enterprise Security Engineer](https://example.com/jobs/1)", synthesized_html_md)
64 context = render.render_context(report)
65 self.assertIn("Hiring Signals", context)
66 self.assertIn("[Enterprise Security Engineer](https://example.com/jobs/1)", context)
67
68 def test_standard_mode_omits_weak_signal(self):
69 report = schema.Report(
70 topic="Apple",
71 range_from="2026-05-16",
72 range_to="2026-06-16",
73 generated_at="2026-06-16T00:00:00Z",
74 provider_runtime=schema.ProviderRuntime("mock", "mock", "mock"),
75 query_plan=schema.QueryPlan(
76 intent="product",
77 freshness_mode="balanced_recent",
78 cluster_mode="none",
79 raw_topic="Apple",
80 subqueries=[],
81 source_weights={},
82 ),
83 clusters=[],
84 ranked_candidates=[],
85 items_by_source={},
86 errors_by_source={},
87 artifacts={
88 "hiring_signals": {
89 "mode": "standard",
90 "company_size_tier": "mega-cap",
91 "include": False,
92 "signals": [],
93 "omitted_reason": "jobs evidence is too diffuse",
94 }
95 },
96 )
97 self.assertEqual([], render._render_hiring_signals(report))
98
99
100 if __name__ == "__main__":
101 unittest.main()
102
103
104 class JobsFooterTests(unittest.TestCase):
105 def test_jobs_only_run_still_emits_law5_footer(self):
106 report = schema.Report(
107 topic="Listen Labs",
108 range_from="2026-05-16",
109 range_to="2026-06-16",
110 generated_at="2026-06-16T00:00:00Z",
111 provider_runtime=schema.ProviderRuntime("mock", "mock", "mock"),
112 query_plan=schema.QueryPlan(
113 intent="product", freshness_mode="balanced_recent", cluster_mode="none",
114 raw_topic="Listen Labs", subqueries=[], source_weights={},
115 ),
116 clusters=[], ranked_candidates=[],
117 items_by_source={
118 "jobs": [
119 schema.SourceItem(
120 item_id="AB1", source="jobs",
121 title="Founding Research Scientist, Human Simulation",
122 body="", url="https://jobs.ashbyhq.com/listenlabs/abc",
123 engagement={"open_roles": 1},
124 )
125 ]
126 },
127 errors_by_source={},
128 artifacts={},
129 )
130 footer = "\n".join(render._render_emoji_footer(report, "/tmp/x.md"))
131 self.assertIn("All agents reported back", footer)
132 self.assertIn("Jobs: 1 role", footer)
133
134
135 class HiringSignalsBannerSuppressionTests(unittest.TestCase):
136 def _report(self):
137 return schema.Report(
138 topic="Listen Labs", range_from="2026-05-16", range_to="2026-06-16",
139 generated_at="2026-06-16T00:00:00Z",
140 provider_runtime=schema.ProviderRuntime("mock", "mock", "mock"),
141 query_plan=schema.QueryPlan(
142 intent="concept", freshness_mode="evergreen_ok", cluster_mode="none",
143 raw_topic="Listen Labs", subqueries=[], source_weights={}),
144 clusters=[], ranked_candidates=[], items_by_source={}, errors_by_source={},
145 artifacts={"plan_source": "deterministic", "hiring_signals_mode": True},
146 )
147
148 def test_hiring_signals_suppresses_degraded_and_pre_research_banners(self):
149 report = self._report()
150 self.assertEqual([], render._render_degraded_run_warning(report))
151 self.assertEqual([], render._render_pre_research_warning(report))
152
153 def test_non_hiring_named_entity_still_warns(self):
154 report = self._report()
155 report.artifacts["hiring_signals_mode"] = False
156 self.assertTrue(render._render_degraded_run_warning(report))
157
157 lines PYTHON