Merge branch 'worktree-agent-afad54f12aef2cccf'
# Conflicts: # app/storage/schema.py # app/storage/store.py # tests/test_storage.py
This commit is contained in:
commit
706b127bc0
10 files changed
+459
-37
No files matched your search
+101
-5
@@ -43,6 +43,16 @@ def test_greenhouse_parses_titles_locations_and_html_description() -> None:
|
||||
assert first["remote"] is None
|
||||
|
||||
|
||||
def test_greenhouse_reads_pay_input_ranges_and_skips_an_hourly_one() -> None:
|
||||
rows = _rows("greenhouse")
|
||||
assert (rows[0]["salary_min"], rows[0]["salary_max"], rows[0]["currency"]) == \
|
||||
(65000, 85000, "EUR")
|
||||
# "SF Bay Area Hourly Rate" is skipped: a yearly figure invented from an
|
||||
# hourly one would be wrong.
|
||||
assert (rows[1]["salary_min"], rows[1]["salary_max"], rows[1]["currency"]) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
def test_lever_parses_categories_and_workplace_type() -> None:
|
||||
rows = _rows("lever")
|
||||
assert [r["source_id"] for r in rows] == ["2001", "2002"]
|
||||
@@ -54,6 +64,14 @@ def test_lever_parses_categories_and_workplace_type() -> None:
|
||||
assert rows[1]["posted"] is None
|
||||
|
||||
|
||||
def test_lever_reads_salary_range_and_skips_an_hourly_wage() -> None:
|
||||
rows = _rows("lever")
|
||||
assert (rows[0]["salary_min"], rows[0]["salary_max"], rows[0]["currency"]) == \
|
||||
(90000, 120000, "EUR")
|
||||
assert (rows[1]["salary_min"], rows[1]["salary_max"], rows[1]["currency"]) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
def test_ashby_parses_is_remote_and_compensation() -> None:
|
||||
rows = _rows("ashby")
|
||||
assert [r["source_id"] for r in rows] == ["3001", "3002"]
|
||||
@@ -62,6 +80,16 @@ def test_ashby_parses_is_remote_and_compensation() -> None:
|
||||
assert rows[1]["remote"] is True
|
||||
|
||||
|
||||
def test_ashby_reads_summary_components_only_with_includecompensation() -> None:
|
||||
# summaryComponents only appears with ?includeCompensation=true on the
|
||||
# feed URL (see _BOARDS); the second job has no compensation key at all.
|
||||
rows = _rows("ashby")
|
||||
assert (rows[0]["salary_min"], rows[0]["salary_max"], rows[0]["currency"]) == \
|
||||
(70000, 90000, "EUR")
|
||||
assert (rows[1]["salary_min"], rows[1]["salary_max"], rows[1]["currency"]) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
def test_workable_builds_the_job_url_and_reads_location_and_remote() -> None:
|
||||
rows = _rows("workable", slug="huggingface")
|
||||
assert [r["source_id"] for r in rows] == ["6125026", "6125041"]
|
||||
@@ -88,6 +116,10 @@ def test_recruitee_parses_salary_bounds_and_careers_url() -> None:
|
||||
assert rows[0]["url"] == "https://acme.example/o/player-support-agent-german-1"
|
||||
assert rows[0]["salary"] == "35000-45000 EUR"
|
||||
assert rows[1]["salary"] == ""
|
||||
assert (rows[0]["salary_min"], rows[0]["salary_max"], rows[0]["currency"]) == \
|
||||
(35000, 45000, "EUR")
|
||||
assert (rows[1]["salary_min"], rows[1]["salary_max"], rows[1]["currency"]) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
def test_personio_builds_the_job_url_and_reads_cdata_description() -> None:
|
||||
@@ -99,16 +131,80 @@ def test_personio_builds_the_job_url_and_reads_cdata_description() -> None:
|
||||
assert rows[1]["remote"] is None # "Munich"
|
||||
|
||||
|
||||
def test_personio_reads_salary_information_when_present() -> None:
|
||||
rows = _rows("personio", slug="acme")
|
||||
assert (rows[0]["salary_min"], rows[0]["salary_max"], rows[0]["currency"]) == \
|
||||
(42000, 55000, "EUR")
|
||||
assert (rows[1]["salary_min"], rows[1]["salary_max"], rows[1]["currency"]) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
# ------------------------------------------------------------ salary math
|
||||
|
||||
def test_yearly_amount_converts_a_monthly_range_by_12() -> None:
|
||||
assert ats._yearly_amount(3000, 4000, "eur", "month", {"year": 1, "month": 12}) == \
|
||||
(36000, 48000, "EUR")
|
||||
|
||||
|
||||
def test_yearly_amount_ignores_a_range_with_no_currency() -> None:
|
||||
assert ats._yearly_amount(3000, 4000, "", "year", {"year": 1, "month": 12}) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
def test_yearly_amount_skips_an_interval_outside_the_factor_table() -> None:
|
||||
# An hourly or a daily rate: a yearly figure invented from it would be
|
||||
# wrong, so it is left out rather than multiplied by a guess.
|
||||
assert ats._yearly_amount(20, 30, "usd", "hour", {"year": 1, "month": 12}) == \
|
||||
(None, None, "")
|
||||
|
||||
|
||||
def test_greenhouse_salary_skips_more_than_one_range() -> None:
|
||||
# Several ranges (one per office/zone) give no way to tell which one the
|
||||
# role in hand is at, so all of them are left out rather than guessed.
|
||||
ranges = [
|
||||
{"min_cents": 100000, "max_cents": 200000, "currency_type": "EUR", "title": "Zone 1"},
|
||||
{"min_cents": 90000, "max_cents": 180000, "currency_type": "EUR", "title": "Zone 2"},
|
||||
]
|
||||
assert ats._greenhouse_salary(ranges) == (None, None, "")
|
||||
|
||||
|
||||
# --------------------------------------------------------------- classify
|
||||
|
||||
def test_classify_matches_department_before_title() -> None:
|
||||
assert ats.classify("Engineering", "Marketing Lead") == "engineering"
|
||||
assert ats.classify("", "Senior Backend Engineer") == "engineering"
|
||||
def test_classify_matches_title_before_department() -> None:
|
||||
# A specific title beats a generic department (see classify's docstring
|
||||
# for the hand-checked sample this is based on).
|
||||
assert ats.classify("Engineering", "Marketing Lead") == "marketing"
|
||||
assert ats.classify("Operations", "Senior Backend Engineer") == "engineering"
|
||||
assert ats.classify("", "Product Manager, Payments") == "product"
|
||||
assert ats.classify("", "Data Product Manager") == "product"
|
||||
assert ats.classify("", "Machine Learning Engineer") == "data"
|
||||
assert ats.classify("", "Executive Assistant to the CEO") == "finance/legal/ops"
|
||||
assert ats.classify("", "") == "other"
|
||||
# The department is still the fallback when the title matches nothing.
|
||||
assert ats.classify("Engineering", "") == "engineering"
|
||||
# Nothing matches either: '', not "other", which would claim a
|
||||
# knowledge the classifier does not have.
|
||||
assert ats.classify("", "") == ""
|
||||
assert ats.classify("", "Chief Bottle Washer") == ""
|
||||
|
||||
|
||||
def test_classify_matches_whole_words_not_substrings() -> None:
|
||||
# "it" used to match inside "Italy"/"Italia" ("IT" meant the department,
|
||||
# not the country), filing a sales role as engineering.
|
||||
assert ats.classify("Commercial Italy", "Account Manager - Liguria") == "sales"
|
||||
assert ats.classify("IT", "") == "engineering"
|
||||
assert ats.classify("", "Marketing Lead, Seoul") == "marketing"
|
||||
# A stem still matches its suffixed forms: "Engineering" the department,
|
||||
# not just "engineer" the exact word.
|
||||
assert ats.classify("Engineering", "") == "engineering"
|
||||
assert ats.classify("", "Software Developers") == "engineering"
|
||||
|
||||
|
||||
def test_classify_understands_a_modest_set_of_other_languages() -> None:
|
||||
assert ats.classify("", "Senior Entwickler (m/w/d)") == "engineering"
|
||||
assert ats.classify("", "Vertriebsmitarbeiter (m/w/d)") == "sales"
|
||||
assert ats.classify("", "Ontwikkelaar") == "engineering"
|
||||
assert ats.classify("", "Udvikler") == "engineering"
|
||||
assert ats.classify("", "Ingénieur logiciel") == "engineering"
|
||||
|
||||
|
||||
# ------------------------------------------------------------- allow-list
|
||||
@@ -166,7 +262,7 @@ def test_fetch_rows_retries_greenhouse_without_content_on_a_too_large_body(
|
||||
rows, complete = ats._fetch_rows(object(), "greenhouse:acme") # type: ignore[arg-type]
|
||||
|
||||
assert calls == [
|
||||
"https://boards-api.greenhouse.io/v1/boards/acme/jobs?content=true",
|
||||
"https://boards-api.greenhouse.io/v1/boards/acme/jobs?content=true&pay_transparency=true",
|
||||
"https://boards-api.greenhouse.io/v1/boards/acme/jobs",
|
||||
]
|
||||
assert [r["source_id"] for r in rows] == ["1001", "1002"]
|
||||
|
||||
Reference in new issue
Block a user