Integration check: wp-p-prep with wp-r1-raw and wp-r2-raw
Resolves tests/test_readers_shared.py, adds MATCH_MODE to the pinpoint, recruitee and rippling tables, and removes table_word, country_if_single and remote_word from plugins/readers/_shared.py with their tests and the Helpers paragraph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
55757c41e5
51 files changed
+445
-502
No files matched your search
@@ -1,8 +1,9 @@
|
||||
"""The helpers the host modules share, and the one employment vocabulary."""
|
||||
"""The helpers the host modules share, and the readers' copy of the one
|
||||
employment vocabulary. The host word tables are prep's
|
||||
(`app/prep/hosts`), held to the vocabularies by `tests/test_prep.py`."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
@@ -11,38 +12,15 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from plugins import readers # noqa: E402
|
||||
from plugins.readers import _shared # noqa: E402
|
||||
from plugins.readers._shared import ( # noqa: E402
|
||||
EMPLOYMENTS,
|
||||
add_place,
|
||||
country_if_single,
|
||||
place,
|
||||
remote_word,
|
||||
table_word,
|
||||
)
|
||||
from plugins.readers._shared import EMPLOYMENTS, add_place, place # noqa: E402
|
||||
|
||||
#: The module-level names a reader keeps its employment words in.
|
||||
_TABLES = ("_EMPLOYMENT", "_CONTRACT", "_SCHEDULE")
|
||||
|
||||
#: The readers of `ashby` to `lever` hand on the host's words; their tables
|
||||
#: moved to `app/prep/hosts`.
|
||||
_RAW = {"ashby", "bamboohr", "deel", "eightfold", "gem", "greenhouse", "hibob", "hrmanager",
|
||||
"jibe", "jobylon", "lever"}
|
||||
#: The module-level names a reader kept its word tables in.
|
||||
_TABLES = ("_SENIORITY", "_EMPLOYMENT", "_CONTRACT", "_SCHEDULE", "_REMOTE")
|
||||
|
||||
|
||||
def test_every_employment_table_maps_into_the_shared_vocabulary() -> None:
|
||||
found = 0
|
||||
def test_no_reader_keeps_a_word_table() -> None:
|
||||
for name, module in readers.READERS.items():
|
||||
assert not _RAW & {name} or not any(hasattr(module, t) for t in _TABLES), name
|
||||
for table_name in _TABLES:
|
||||
table = getattr(module, table_name, None)
|
||||
if table is None:
|
||||
continue
|
||||
found += 1
|
||||
values = table.values() if isinstance(table, dict) else [v for _k, v in table]
|
||||
# "" is a known word that names no employment ("permanent").
|
||||
assert set(values) <= {*EMPLOYMENTS, ""}, (name, table_name)
|
||||
assert found >= 5
|
||||
assert not [t for t in _TABLES if hasattr(module, t)], name
|
||||
|
||||
|
||||
def test_the_vocabulary_is_the_documented_one() -> None:
|
||||
@@ -64,28 +42,3 @@ def test_add_place_skips_empty_and_repeated_texts_and_keeps_order() -> None:
|
||||
for text in ("Berlin", "", "Oslo", "Berlin"):
|
||||
add_place(found, place(text))
|
||||
assert [p["text"] for p in found] == ["Berlin", "Oslo"]
|
||||
|
||||
|
||||
def test_table_word_maps_ignores_case_and_logs_only_unknown_words(caplog) -> None:
|
||||
table = {"full-time": "full_time", "permanent": ""}
|
||||
log = logging.getLogger("plugins.readers.acme")
|
||||
with caplog.at_level(logging.DEBUG, logger=log.name):
|
||||
assert table_word(table, " Full-Time ", log, "type") == "full_time"
|
||||
assert table_word(table, "Permanent", log, "type") is None
|
||||
assert table_word(table, None, log, "type") is None
|
||||
assert not caplog.records
|
||||
assert table_word(table, "Odd", log, "type") is None
|
||||
assert [r.getMessage() for r in caplog.records] == ["acme: unknown type 'Odd'"]
|
||||
|
||||
|
||||
def test_country_if_single_needs_exactly_one_code() -> None:
|
||||
assert country_if_single({"DE"}) == "DE"
|
||||
assert country_if_single({"DE", "SE"}) is None
|
||||
assert country_if_single(set()) is None
|
||||
|
||||
|
||||
def test_remote_word_reads_danish_swedish_and_english() -> None:
|
||||
assert remote_word("Remote, Danmark") == "remote"
|
||||
assert remote_word("Birkerød, Hybrid position") == "hybrid"
|
||||
assert remote_word("Hedehusene") is None
|
||||
assert _shared.remote_word is remote_word
|
||||
Reference in new issue
Block a user