返回 last30days-skill
test_hiring_signals.py
根目录 / tests / test_hiring_signals.py
1 import unittest
2
3 from lib import hiring_signals, schema
4
5
6 def job(title: str, body: str, department: str = "Engineering") -> schema.SourceItem:
7 return schema.SourceItem(
8 item_id=title,
9 source="jobs",
10 title=title,
11 body=body,
12 url=f"https://example.com/jobs/{title.replace(' ', '-').lower()}",
13 container=department,
14 published_at="2026-06-01",
15 date_confidence="high",
16 metadata={"department": department},
17 )
18
19
20 class HiringSignalsTests(unittest.TestCase):
21 def test_startup_cluster_surfaces_in_standard_mode(self):
22 items = [
23 job("Founding Enterprise Solutions Engineer", "SSO SOC 2 procurement enterprise", "Sales"),
24 job("Security Platform Engineer", "enterprise security audit admin", "Engineering"),
25 ]
26 summary = hiring_signals.analyze(items, explicit=False, topic="Listen Labs")
27 self.assertTrue(summary["include"])
28 self.assertEqual("startup", summary["company_size_tier"])
29 self.assertEqual("enterprise readiness", summary["signals"][0]["theme"])
30
31 def test_mega_cap_scattered_roles_do_not_surface_standard_mode(self):
32 items = [
33 job("Retail Associate", "store operations", "Retail"),
34 job("iOS Engineer", "mobile app", "Engineering"),
35 job("Finance Analyst", "planning", "Finance"),
36 ]
37 summary = hiring_signals.analyze(items, explicit=False, topic="Apple")
38 self.assertFalse(summary["include"])
39 self.assertEqual("mega-cap", summary["company_size_tier"])
40 self.assertIn("too diffuse", summary["omitted_reason"])
41
42 def test_fortune_500_customer_boilerplate_does_not_make_startup_large_enterprise(self):
43 items = [
44 job(
45 "Founding Enterprise Solutions Engineer",
46 "Help Fortune 500 customers adopt SSO, SOC 2, and procurement workflows.",
47 "Sales",
48 ),
49 job(
50 "Security Platform Engineer",
51 "Build enterprise security, audit, and admin workflows for Fortune 500 customers.",
52 "Engineering",
53 ),
54 ]
55 summary = hiring_signals.analyze(items, explicit=False, topic="Listen Labs")
56 self.assertEqual("startup", summary["company_size_tier"])
57 self.assertTrue(summary["include"])
58
59 def test_explicit_mode_keeps_low_confidence_signal(self):
60 items = [job("Customer Success Manager", "support enterprise customers", "Success")]
61 summary = hiring_signals.analyze(items, explicit=True, topic="Acme")
62 self.assertTrue(summary["include"])
63 self.assertEqual("low", summary["signals"][0]["confidence"])
64
65 def test_founding_specialized_role_surfaces_as_strategic_candidate(self):
66 # The exact 2026-06-15 miss: one strategic role amid many generic ones.
67 items = [
68 job("Software Engineer", "backend services", "Engineering"),
69 job("Software Engineer, Backend", "platform", "Engineering"),
70 job("Software Engineer, Frontend", "ui", "Engineering"),
71 job("Founding Research Scientist, Human Simulation", "simulate users", "Research"),
72 ]
73 summary = hiring_signals.analyze(items, explicit=True, topic="Listen Labs")
74 titles = [c["title"] for c in summary["strategic_candidates"]]
75 self.assertIn("Founding Research Scientist, Human Simulation", titles)
76 top = summary["strategic_candidates"][0]
77 self.assertEqual("Founding Research Scientist, Human Simulation", top["title"])
78 self.assertIn("founding", top["flags"])
79 self.assertIn("specialized", top["flags"])
80
81 def test_specialization_ignores_generic_level_qualifiers(self):
82 self.assertEqual("", hiring_signals._specialization("Engineer, Senior"))
83 self.assertEqual("Human Simulation", hiring_signals._specialization("Research Scientist, Human Simulation"))
84 self.assertEqual("Forward Deployed", hiring_signals._specialization("Engineer (Forward Deployed)"))
85
86 def test_new_geo_flag_for_rare_location(self):
87 def loc_job(title, location):
88 it = job(title, "work", "Engineering")
89 it.metadata["location"] = location
90 return it
91 items = [
92 loc_job("Engineer A", "San Francisco"),
93 loc_job("Engineer B", "San Francisco"),
94 loc_job("Engineer C", "San Francisco"),
95 loc_job("Growth Lead", "New York"),
96 ]
97 summary = hiring_signals.analyze(items, explicit=True, topic="Acme")
98 ny = [c for c in summary["strategic_candidates"] if c["location"] == "new york"]
99 self.assertTrue(ny)
100 self.assertIn("new-geo", ny[0]["flags"])
101
102
103 if __name__ == "__main__":
104 unittest.main()
105
105 lines PYTHON