"""Scout selection regressions from the 2026-09-11 review (F11 onwards). These are the cases where a bug silently removed or mis-ranked a role *before* any human judgement happened, which is the expensive kind: a job that never reaches the report cannot be evaluated at all. """ from __future__ import annotations import sys import unittest from pathlib import Path ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / "job_scout")) import scout # noqa: E402 def process(jobs, cid="acme", display="Acme"): results, stat, warnings = scout._process_company( cid, display, {}, jobs, {}, "2026-09-11", {}) return results, stat, warnings class RequisitionDedupeTests(unittest.TestCase): """F11: title is not identity.""" def test_two_requisitions_sharing_a_title_both_survive(self): jobs = [ {"id": "R-1", "title": "Senior Data Engineer", "location": "Bern, Switzerland", "url": "https://acme.example/jobs/R-1"}, {"id": "R-2", "title": "Senior Data Engineer", "location": "Zurich, Switzerland", "url": "https://acme.example/jobs/R-2"}, ] results, _, warnings = process(jobs) self.assertEqual(2, len(results), "a different requisition must never be dropped") self.assertTrue(any("title(s) shared by different requisitions" in message for _, message in warnings), "the collision should be reported, not silently resolved") def test_same_requisition_republished_per_location_is_merged(self): jobs = [ {"id": "R-9", "title": "Platform Engineer | Switzerland | Remote", "location": "Bern, Switzerland", "url": "https://acme.example/jobs/R-9"}, {"id": "R-9", "title": "Platform Engineer | Germany | Remote", "location": "Munich, Germany", "url": "https://acme.example/jobs/R-9"}, ] results, _, _ = process(jobs) self.assertEqual(1, len(results), "one requisition should stay one row") self.assertIn("Bern", results[0]["location"]) def test_distinct_titles_are_unaffected(self): jobs = [ {"id": "A", "title": "Data Engineer", "location": "Bern, Switzerland", "url": "https://acme.example/jobs/A"}, {"id": "B", "title": "Platform Engineer", "location": "Bern, Switzerland", "url": "https://acme.example/jobs/B"}, ] results, _, warnings = process(jobs) self.assertEqual(2, len(results)) self.assertEqual([], [m for _, m in warnings if "title(s) shared" in m]) if __name__ == "__main__": unittest.main()