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>
45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
"""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 sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
if str(ROOT) not in sys.path:
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from plugins import readers # noqa: E402
|
|
from plugins.readers._shared import EMPLOYMENTS, add_place, place # noqa: E402
|
|
|
|
#: The module-level names a reader kept its word tables in.
|
|
_TABLES = ("_SENIORITY", "_EMPLOYMENT", "_CONTRACT", "_SCHEDULE", "_REMOTE")
|
|
|
|
|
|
def test_no_reader_keeps_a_word_table() -> None:
|
|
for name, module in readers.READERS.items():
|
|
assert not [t for t in _TABLES if hasattr(module, t)], name
|
|
|
|
|
|
def test_the_vocabulary_is_the_documented_one() -> None:
|
|
assert EMPLOYMENTS == ("full_time", "part_time", "contract", "temporary", "internship",
|
|
"freelance")
|
|
|
|
|
|
def test_place_is_remote_on_the_word_and_otherwise_as_stated() -> None:
|
|
assert place("Remote (DE)") == {"text": "Remote (DE)", "remote": True}
|
|
assert place("Berlin, remote") == {"text": "Berlin, remote", "remote": True}
|
|
assert place("Berlin") == {"text": "Berlin", "remote": None}
|
|
assert place("Berlin", False) == {"text": "Berlin", "remote": False}
|
|
assert place("Remote", False)["remote"] is True
|
|
assert place("Remotely", None)["remote"] is None
|
|
|
|
|
|
def test_add_place_skips_empty_and_repeated_texts_and_keeps_order() -> None:
|
|
found: list = []
|
|
for text in ("Berlin", "", "Oslo", "Berlin"):
|
|
add_place(found, place(text))
|
|
assert [p["text"] for p in found] == ["Berlin", "Oslo"]
|