You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.5 KiB
Python

"""Tests for cross-source duplicate merging (doc §19)."""
from gimme_job.proactive.engine import ProactiveEngine
from gimme_job.proactive.engines import SearchResult
from gimme_job.proactive.plan import ProactivePlan
def _res(title: str, url: str, employer: str = "ACME") -> SearchResult:
return SearchResult(title=title, url=url, employer_hint=employer, source="x")
def test_merge_prefers_official_ats_over_aggregator():
plan = ProactivePlan.load()
agg = _res("Orthodontist", "https://www.indeed.com/jobs/1")
ats = _res("Orthodontist", "https://wd5.myworkdayjobs.com/acme/job/123")
merged = ProactiveEngine._merge_duplicates([agg, ats], plan)
assert len(merged) == 1
assert "myworkdayjobs.com" in merged[0].url
assert merged[0].secondary_urls == ["https://www.indeed.com/jobs/1"]
def test_no_merge_when_different_jobs():
plan = ProactivePlan.load()
a = _res("Orthodontist", "https://a.org/1")
b = _res("Dentist", "https://a.org/2")
assert len(ProactiveEngine._merge_duplicates([a, b], plan)) == 2
def test_no_merge_when_different_employers():
plan = ProactivePlan.load()
a = _res("Orthodontist", "https://a.org/1", employer="Acme")
b = _res("Orthodontist", "https://b.org/1", employer="Beta")
assert len(ProactiveEngine._merge_duplicates([a, b], plan)) == 2
def test_single_result_kept():
plan = ProactivePlan.load()
a = _res("Orthodontist", "https://a.org/1")
assert ProactiveEngine._merge_duplicates([a], plan) == [a]