Wire freehire, Jobnet and Akademikernes Jobbank into the CLI, the Sources form, dupes and the docs
Provider names, the CLI's choices and the dupes rule's search hosts now come from readers.PROVIDERS, and the regions, work modes and remote words from the modules' REGIONS, MODES and REMOTE, read with getattr so main works before and after the readers merge. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
018a1ad895
commit
6e6e655203
16 files changed
+422
-39
No files matched your search
+71
-1
@@ -576,7 +576,7 @@ def test_search_params_keeps_only_what_the_provider_reads() -> None:
|
||||
def test_the_providers_and_their_params_follow_the_reader_declarations() -> None:
|
||||
from plugins import readers
|
||||
|
||||
assert sources.PROVIDERS == tuple(readers.PROVIDERS) == ("jobindex", "adzuna", "platsbanken")
|
||||
assert tuple(readers.PROVIDERS)[:3] == ("jobindex", "adzuna", "platsbanken")
|
||||
assert sources.search_params("adzuna", " backend ", country=" DE ", where=" Berlin ",
|
||||
area=1, region="x", pages=2) == {
|
||||
"q": "backend", "country": "de", "where": "Berlin", "pages": 2}
|
||||
@@ -589,3 +589,73 @@ def test_search_params_refuses_a_region_that_is_no_swedish_lan() -> None:
|
||||
sources.search_params("platsbanken", "data", region="zYpL_aGk_QY8") # Midland
|
||||
with pytest.raises(ValueError, match="provider"):
|
||||
sources.search_params("indeed", "data")
|
||||
|
||||
|
||||
def test_search_params_of_the_three_newer_providers_follow_their_declarations(
|
||||
search_stubs: dict[str, Any]) -> None:
|
||||
assert sources.search_params("freehire", " head of data ", country=" DK,se ",
|
||||
remote="remote", area=1, region="x", pages=2) == {
|
||||
"q": "head of data", "country": "dk,se", "remote": "remote", "pages": 2}
|
||||
assert sources.search_params("jobnet", "data", region="Midtjylland", country="dk",
|
||||
remote="remote") == {"q": "data", "region": "Midtjylland"}
|
||||
assert sources.search_params("jobbank", "data", region="2", remote="helt") == {
|
||||
"q": "data", "region": "2", "remote": "helt"}
|
||||
with pytest.raises(ValueError, match="region"):
|
||||
sources.search_params("jobnet", "data", region="Fyn")
|
||||
with pytest.raises(ValueError, match="remote"):
|
||||
sources.search_params("freehire", "data", remote="helt")
|
||||
|
||||
|
||||
def test_the_provider_error_lists_the_loaded_readers(search_stubs: dict[str, Any]) -> None:
|
||||
with pytest.raises(ValueError, match=r"freehire.*jobnet.*jobbank"):
|
||||
sources.search_params("indeed", "data")
|
||||
|
||||
|
||||
def test_a_provider_table_is_empty_for_a_reader_that_is_not_loaded(
|
||||
search_stubs: dict[str, Any], monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
from plugins import readers
|
||||
|
||||
assert sources.provider_table("jobbank", "REMOTE") == {
|
||||
"helt": "Fully remote", "delvist": "Partly remote"}
|
||||
assert sources.provider_table("freehire", "REGIONS") == {} # it declares none
|
||||
monkeypatch.delitem(readers.PROVIDERS, "jobbank")
|
||||
assert sources.provider_table("jobbank", "REGIONS") == {}
|
||||
assert sources.provider_table("nobody", "MODES") == {}
|
||||
|
||||
|
||||
def test_cli_searches_add_takes_the_newer_providers_and_their_flags(
|
||||
search_stubs: dict[str, Any], store: Store, tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]) -> None:
|
||||
monkeypatch.setattr(sources, "try_search", lambda config, provider, name, params: (
|
||||
[{"title": "Data lead", "company": "Acme", "place": "København",
|
||||
"url": "https://x.example/1"}], True))
|
||||
config = tmp_path / "config.yaml"
|
||||
config.write_text(f"database: {store.path}\n")
|
||||
|
||||
def add(*argv: str) -> int:
|
||||
return main(["-c", str(config), "searches", "add", *argv])
|
||||
|
||||
assert add("freehire", "Head of data", "--q", "head of data", "--country", "DK,SE",
|
||||
"--remote", "hybrid") == 0
|
||||
assert add("jobnet", "Data science", "--q", "data science", "--region",
|
||||
"HovedstadenOgBornholm") == 0
|
||||
assert add("jobbank", "Data director", "--q", "data director", "--region", "2",
|
||||
"--remote", "delvist") == 0
|
||||
capsys.readouterr()
|
||||
saved = {s.board: s.params for s in store.subscriptions(source="search")}
|
||||
assert saved == {
|
||||
"freehire": {"q": "head of data", "country": "dk,se", "remote": "hybrid"},
|
||||
"jobnet": {"q": "data science", "region": "HovedstadenOgBornholm"},
|
||||
"jobbank": {"q": "data director", "region": "2", "remote": "delvist"}}
|
||||
assert add("jobnet", "Bad", "--q", "x", "--region", "Fyn") == 1
|
||||
assert "region" in capsys.readouterr().err
|
||||
|
||||
|
||||
def test_cli_searches_add_help_names_the_regions_and_work_modes(
|
||||
search_stubs: dict[str, Any], capsys: pytest.CaptureFixture[str]) -> None:
|
||||
with pytest.raises(SystemExit):
|
||||
main(["searches", "add", "-h"])
|
||||
text = " ".join(capsys.readouterr().out.split())
|
||||
assert "freehire" in text and "jobnet" in text and "jobbank" in text
|
||||
assert "HovedstadenOgBornholm" in text and "2 Storkøbenhavn" in text
|
||||
assert "hybrid Hybrid" in text and "helt Fully remote" in text
|
||||
Reference in new issue
Block a user