Merge the jobnet search reader (wp-src-jobnet)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
ee17fe3e30
5 files changed
+545
No files matched your search
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"jobAds": [],
|
||||
"totalJobAdCount": 20684,
|
||||
"searchString": ""
|
||||
}
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
{
|
||||
"jobAds": [
|
||||
{
|
||||
"country": "Danmark",
|
||||
"municipality": "Frederiksberg",
|
||||
"postalCode": 2000,
|
||||
"postalDistrictName": "Frederiksberg",
|
||||
"hiringOrgName": "Mywok ApS",
|
||||
"occupation": "Kok",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/68c9d4ce-3dfe-45ec-aa21-6ea6bed91035",
|
||||
"jobAnnouncementTypeName": "Hotjob",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "5e6a1854-803f-4102-9dcc-e7cffeabb278",
|
||||
"jobAdUrl": "",
|
||||
"hasLogo": false,
|
||||
"workPlaceAddress": "",
|
||||
"cvr": "45458962",
|
||||
"title": "kok til asiatisk takeaway",
|
||||
"description": "<p>Er du passioneret omkring kinesisk mad? har du et skarpt øje for detaljer og elsker at arbjde i et pulserende, hurtigt miljø? Så er du måske vores nye kollega!</p><p>Mywok i frederiksberg søger 2 dygtige og engageret kok til vores køkken, der kan bringe deres erfaring og kreativitet til vores team.</p><p>Arbejdsopgaver:</p><p>Forberedelse og tilberedning af asiatisk retter at opretholde en høj standard for renlighed oh hygiejne i køkkenet bidrage med ideer til menuopdateringer og sæsonbestemte tilbud.</p><p>Dine kvalifikationer</p><p>Du har erfaring fra lignende stillinger, og du er fortrolig med at arbejde i et travlt køkken, Du har en solid viden om og erfaring med at lave asiatisk retter.</p><p>Du arbejder effektivt og kan håndtere tralhed i køkkenet. Du er ansvarlig og kan arbejde selvstændigt såvel som i et team</p>",
|
||||
"applicationDeadline": "2026-10-31T00:00:00+01:00",
|
||||
"applicationDeadlineSort": "2026-10-31T00:00:00+01:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": false,
|
||||
"publicationDate": "2026-10-03T00:00:00+02:00"
|
||||
},
|
||||
{
|
||||
"country": "Danmark",
|
||||
"municipality": "Gladsaxe",
|
||||
"postalCode": 2860,
|
||||
"postalDistrictName": "Søborg",
|
||||
"hiringOrgName": "Simba Automation APS",
|
||||
"occupation": "Taxichauffør",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/4ce98c22-8794-4105-bd71-8bf18a47bd00",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "db54d22c-3742-4bc7-9100-c2c3edf4cea3",
|
||||
"jobAdUrl": "",
|
||||
"hasLogo": false,
|
||||
"workPlaceAddress": "",
|
||||
"cvr": "39504065",
|
||||
"title": "Taxichauffør - Fuldtid, Deltid, Afløser",
|
||||
"description": "<p><strong>En af de gamle vognmænd fra 1990'erne søger taxichauffører</strong></p>\n<p>Vi søger <strong>Stabil, Flittig, Professionel, Venlige og Erfarne</strong> taxichauffører til at blive en del af vores virksomhed. Som taxichauffør vil dine ansvarsområder omfatte at hente kunder, transportere dem til deres destinationer og håndtere betalinger. Dit mål er at sikre sikre og behagelige rejser for passagererne. Køretøjets vedligeholdelse hold taxaen ren og i fremragende stand.</p>\n<p>Vi tilbyder både <strong>Deltids og Fuldtidsstillinger samt Weekendvagter.</strong> Desuden har vi både <strong>El-Taxier og Diesel-Taxier</strong>. Muligvis få taxier alene med hjem!</p>\n<p><strong>Krav:</strong></p>",
|
||||
"applicationDeadline": "2026-11-23T00:00:00+01:00",
|
||||
"applicationDeadlineSort": "2026-11-23T00:00:00+01:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": false,
|
||||
"publicationDate": "2026-10-02T00:00:00+02:00"
|
||||
},
|
||||
{
|
||||
"country": "Danmark",
|
||||
"postalCode": 2610,
|
||||
"postalDistrictName": "Rødovre",
|
||||
"hiringOrgName": "OLSEN METALTRYKKERI A/S",
|
||||
"occupation": "Maskinoperatør",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/b8ecaf41-d248-4232-ad58-9b3a6a8a4c18",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "f2ed4f3d-03bc-4021-a4f2-48d7fa13c521",
|
||||
"jobAdUrl": "",
|
||||
"hasLogo": true,
|
||||
"workPlaceAddress": "",
|
||||
"cvr": "73418216",
|
||||
"title": "Operatører til metalproduktion",
|
||||
"description": "<p>Til mindre metalproduktion i Rødovre (35 pers.) søger vi nye kollegaer. Du har erfaring med betjening af maskiner til forarbejdning af metal. Gerne betjening af CNC styrede maskiner på operatørniveau.</p><p>Det vi fremstiller er meget nicheorienteret så vi forventer ikke at du kender til vores maskiner, men det er vigtigt at du har en baggrund i metalindustrien så du forstår hvad det handler om når man arbejder med metal.</p><p>Du vil blive oplært i de aktuelle maskiner og vi kan ud over en spændende arbejdsdag med mange forskellige opgaver, tilbyde gode kollegaer, fleksible arbejdstider og et godt arbejdsmiljø.</p><p></p>",
|
||||
"applicationDeadline": "2026-10-30T18:08:37+01:00",
|
||||
"applicationDeadlineSort": "2026-10-30T18:08:37+01:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": false,
|
||||
"publicationDate": "2026-10-02T00:00:00+02:00"
|
||||
},
|
||||
{
|
||||
"country": "Danmark",
|
||||
"municipality": "Roskilde",
|
||||
"postalCode": 4000,
|
||||
"postalDistrictName": "Roskilde",
|
||||
"hiringOrgName": "Roskilde Kommune",
|
||||
"occupation": "Social- og sundhedshjælper",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/6c4558de-7fdd-4de1-921a-bd1d6ab4fe6d",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": true,
|
||||
"jobAdId": "7a79c8ca-9e9b-4a63-af64-8ed59de8ce43",
|
||||
"jobAdUrl": "https://candidate.hr-manager.net/ApplicationInit.aspx?cid=359&ProjectId=206245&MediaId=5",
|
||||
"hasLogo": false,
|
||||
"workPlaceAddress": "Maglehøjen 6 ",
|
||||
"cvr": "29189404",
|
||||
"title": "Talentech - Roskilde Syd 2 søger timelønnede kolleger til den udekørende hjemmepleje",
|
||||
"description": "<p>Vi dækker områderne omkring Gartnervang og Æblehaven.</p>\n<p>Arbejdsopgaverne vil indeholde personlig pleje, samt praktisk hjælp, i borgers egen hjem.</p>\n<ul>\n<li>Du behøver ikke kørekort, men du skal kunne cykle og evt. medbringe din egen.</li>\n<li>Du skal gøre dig forståelig i dansk på skrift og tale.</li>\n<li>Du skal kunne møde kl 7.00 og gerne kunne arbejde hver anden weekend.</li>\n<li>Der vil være god introduktion med bl.a. forflytningsundervisning og undervisning i vores omsorgssystem.</li>\n</ul>\n<p>Vi tilbyder:</p>\n<ul>\n<li>Gode kolleger med fagligt fællesskab, høj tværfaglighed og godt humør.</li>\n<li>Stillinger som er præget af selvstændighed.</li>\n<li>Spændende og udviklende job, hvor alle hjælper hinanden og har ledelsesmæssig opbakning.</li>\n<li>Et spændende og alsidigt arbejde.</li>\n<li>En grundig introduktion.</li>\n</ul>\n<p>Vi bor på Maglehøjen 6, 4000 Roskilde .</p>",
|
||||
"applicationDeadline": "2026-10-19T00:00:00+02:00",
|
||||
"applicationDeadlineSort": "2026-10-19T00:00:00+02:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": true,
|
||||
"publicationDate": "2026-10-03T00:00:00+02:00"
|
||||
},
|
||||
{
|
||||
"country": "Danmark",
|
||||
"municipality": "Haderslev",
|
||||
"postalCode": 6100,
|
||||
"postalDistrictName": "Haderslev",
|
||||
"hiringOrgName": "LINDAB",
|
||||
"occupation": "Produktionsmedarbejder",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/a58222c2-f8c8-4794-832f-8d8806408129",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "070b2b8b-8088-42be-a6a0-38b6a7deec26",
|
||||
"jobAdUrl": "https://www.sydjob.dk/Job/Detaljer/9150398/produktionsmedarbejder-med-handvarksmassig-er",
|
||||
"hasLogo": false,
|
||||
"workPlaceAddress": " ",
|
||||
"cvr": "33124228",
|
||||
"title": "Produktionsmedarbejder med håndværksmæssig erfaring",
|
||||
"description": "<p>Produktionsmedarbejder med håndværksmæssig erfaring</p>\n<p>Er du praktisk anlagt, har du hænderne godt skruet på, og trives du med en hverdag, hvor der bliver arbejdet med metal og produktion fra bunden? Så er det måske dig, vi leder efter.</p>\n<p>Vi søger medarbejdere til vores afdeling, hvor vi fremstiller og samler vores produkter helt fra bunden. Det er en alsidig produktionsafdeling, hvor arbejdsdagen byder på forskellige former for håndværks- og produktionsopgaver.</p>\n<p>Du kommer blandt andet til at arbejde med:</p>\n<p>Valsning<br>\nTrådsvejsning<br>\nPunktsvejsning<br>\nKantkørsel<br>\nBukning<br>\nKalibrering<br>\nSamling og bearbejdning af produkter<br>\nDiverse håndværksmæssige og produktionsrelaterede opgaver</p>",
|
||||
"applicationDeadline": "2026-10-15T23:59:00+02:00",
|
||||
"applicationDeadlineSort": "2026-10-15T23:59:00+02:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": true,
|
||||
"publicationDate": "2026-10-03T00:00:00+02:00"
|
||||
},
|
||||
{
|
||||
"country": "Danmark",
|
||||
"municipality": "Randers",
|
||||
"hiringOrgName": "Logos Payment Solutions A/S",
|
||||
"occupation": "Servicetekniker",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/d71b4a9c-8367-4afa-bf2a-5178b856e591",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "0be3d76e-fee8-48a1-a783-72882dcd1502",
|
||||
"jobAdUrl": "https://www.logospayments.com/da/karriere/",
|
||||
"hasLogo": false,
|
||||
"workPlaceAddress": " ",
|
||||
"cvr": "26393647",
|
||||
"title": "Service tekniker Midtjylland (DK) – Logos Payment Solutions",
|
||||
"description": "<p><strong>Service tekniker Midtjylland (DK) – Logos Payment Solutions</strong></p>\n<p>Selvstændigt job med frihed under ansvar Logos Payment Solutions A/S søger en servicetekniker til installation og service af betalingsløsninger på tankstationer og vaskehaller i Midt- og Nordjylland.</p>\n<p>Du bliver en del af et landsdækkende team på ca. 30 teknikere og får en selvstændig hverdag med udgangspunkt fra din bopæl. Du tilknyttes vores afdeling i Randers og får adgang til sparring, reservedele og gode kollegaer.</p>\n<p>Vi tilbyder:</p>\n<p>• Grundig oplæring og sidemandsoplæring</p>\n<p>• Servicevogn, værktøj, PC og telefon</p>\n<p>• Konkurrencedygtig løn og frihed under ansvar</p>\n<p>• Et uformelt og positivt arbejdsmiljø</p>\n<p>📌 Vi søger dig, der er uddannet elektriker med erfaring, er løsningsorienteret og trives med kundekontakt og varierende arbejdsdage.</p>",
|
||||
"applicationDeadline": "2027-01-03T00:00:00+01:00",
|
||||
"applicationDeadlineSort": "2027-01-03T00:00:00+01:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": true,
|
||||
"publicationDate": "2026-10-03T00:00:00+02:00"
|
||||
}
|
||||
],
|
||||
"totalJobAdCount": 57,
|
||||
"searchString": "data science"
|
||||
}
|
||||
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"jobAds": [
|
||||
{
|
||||
"country": "Tyskland",
|
||||
"hiringOrgName": "Vereinigte Hagelversicherung VVaG",
|
||||
"occupation": "Rådgivende konsulent",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/5bfad078-c6d7-4460-9e65-1d84bce5e650",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "bf2403a6-57b6-4b71-b27c-8847e9f3cf80",
|
||||
"jobAdUrl": "https://germantechjobs.de/jobs/Vereinigte-Hagelversicherung-VVaG-Senior-Data-Analyst-mwd?utm_source=mygoogle_table_results&utm_medium=mygoogle_table_results",
|
||||
"hasLogo": false,
|
||||
"workPlaceAddress": "Wilhelmstraße 25 ",
|
||||
"cvr": "31417619",
|
||||
"title": "Senior Data Analyst (m/w/d)",
|
||||
"description": "<p>To apply for this position, please send your CV and a short motivation letter to jobapplication@devitjobs.com - we only accept applications sent this way.</p>\n<p><strong>Anforderungen</strong></p>\n<p><strong>Muss:</strong></p>",
|
||||
"applicationDeadline": "2027-01-02T00:00:00+01:00",
|
||||
"applicationDeadlineSort": "2027-01-02T00:00:00+01:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": true,
|
||||
"publicationDate": "2026-10-02T00:00:00+02:00"
|
||||
},
|
||||
{
|
||||
"country": "Danmark",
|
||||
"hiringOrgName": "Aalborg Universitet",
|
||||
"occupation": "Adjunkt",
|
||||
"conceptUriDa": "http://data.star.dk/esco/occupation/8ccbb9fe-0536-4a7f-a53a-63009f8f8ccd",
|
||||
"jobAnnouncementTypeName": "Almindelige vilkår",
|
||||
"workHourPartTime": false,
|
||||
"jobAdId": "96ce51c8-4aa6-4056-9a55-7242aa140a05",
|
||||
"jobAdUrl": "https://www.stillinger.aau.dk/videnskabelige-stillinger/vis-stilling/vacancyId/967442",
|
||||
"hasLogo": true,
|
||||
"workPlaceAddress": " ",
|
||||
"cvr": "29102384",
|
||||
"title": "Assistant professor or Assistant professor Tenure Track, Department of Computer Science, Copenhagen Section",
|
||||
"description": "<p><strong>Assistant professor or Assistant professor Tenure Track, Department of Computer Science, Copenhagen Section</strong></p>\n<p>Department of Computer Science, Aalborg University is hiring Assistant professors or Assistant professors Tenure Track starting <strong>February 1, 2027</strong>. The Assistant professor position is a 3-year fixed term full-time position, and the tenure track position, is a structured career pathway with clearly defined criteria for progression to a permanent position upon successful evaluation.</p>\n<p>One position will be affiliated with the research group <a href=\"https://www.cs.aau.dk/research/research-groups/probabilistic-and-symbolic-ai-psai\">Probabilistic and Symbolic AI</a> in the Copenhagen section.</p>",
|
||||
"applicationDeadline": "2026-11-01T00:00:00+01:00",
|
||||
"applicationDeadlineSort": "2026-11-01T00:00:00+01:00",
|
||||
"applicationDeadlineStatus": "ExpirationDate",
|
||||
"isSeen": false,
|
||||
"isFavorite": false,
|
||||
"isJoblogged": false,
|
||||
"isExternal": true,
|
||||
"publicationDate": "2026-09-30T00:00:00+02:00"
|
||||
}
|
||||
],
|
||||
"totalJobAdCount": 5860,
|
||||
"searchString": ""
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
"""The Jobnet reader (`/bff/FindJob/Search`): 100 ads a page, page numbers
|
||||
from 1, the header `x-csrf: 1`. No network: `get` is a stub."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from urllib.parse import parse_qs, urlsplit
|
||||
|
||||
import pytest
|
||||
|
||||
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 import Ask, jobnet # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "search"
|
||||
PLACES = (FIXTURES / "jobnet-places.json").read_bytes()
|
||||
OTHER = (FIXTURES / "jobnet.json").read_bytes()
|
||||
END = (FIXTURES / "jobnet-end.json").read_bytes()
|
||||
|
||||
|
||||
def _stock(total: int | None, stock: int, asked: list[tuple[str, dict[str, str]]]) -> Any:
|
||||
def get(url: str, **kwargs: Any) -> bytes:
|
||||
asked.append((url, kwargs.get("headers") or {}))
|
||||
query = parse_qs(urlsplit(url).query)
|
||||
start = (int(query["pageNumber"][0]) - 1) * int(query["resultsPerPage"][0])
|
||||
size = int(query["resultsPerPage"][0])
|
||||
body: dict[str, Any] = {"jobAds": [
|
||||
{"jobAdId": str(n), "title": f"Role {n}", "jobAdUrl": ""}
|
||||
for n in range(start, min(start + size, stock))]}
|
||||
if total is not None:
|
||||
body["totalJobAdCount"] = total
|
||||
return json.dumps(body).encode()
|
||||
return get
|
||||
|
||||
|
||||
def _rows(body: bytes) -> list[dict[str, Any]]:
|
||||
decoded, *_ = jobnet.page(lambda url, **kw: body, "", None, Ask())
|
||||
return jobnet.rows(decoded, "")
|
||||
|
||||
|
||||
def test_it_is_a_search_reader_naming_the_redirect_and_the_header() -> None:
|
||||
assert readers.PROVIDERS["jobnet"] is jobnet
|
||||
reads = jobnet.READS
|
||||
assert (reads.scope, reads.page_size, reads.ceiling, reads.places, reads.complete) == (
|
||||
"search", 100, 10000, "one", "stated")
|
||||
assert "redirects" in reads.robots and "x-csrf" in reads.robots and "2026-10-03" in reads.robots
|
||||
assert jobnet.PARAMS == {"q": "query", "region": "place"}
|
||||
assert jobnet.allowed("")("jobnet.dk") and not jobnet.allowed("")("example.com")
|
||||
|
||||
|
||||
def test_it_reads_title_company_date_and_the_full_text() -> None:
|
||||
first, taxi, _metal, roskilde, *_ = _rows(PLACES)
|
||||
assert first["source_id"].startswith("5e6a1854-")
|
||||
assert first["title"] == "kok til asiatisk takeaway"
|
||||
assert first["company"] == "Mywok ApS"
|
||||
assert first["country"] == "DK"
|
||||
assert first["posted"].date().isoformat() == "2026-10-03"
|
||||
assert first["description"] and "<" not in first["description"]
|
||||
assert taxi["description"].startswith("## ") # a heading stays one
|
||||
assert roskilde["description"].count("• ") == 9 # a list keeps its bullets
|
||||
assert "remote" not in first and "teaser" not in first
|
||||
|
||||
|
||||
def test_an_ad_without_its_own_link_opens_jobnets_page_for_it() -> None:
|
||||
first, _taxi, _metal, roskilde, *_ = _rows(PLACES)
|
||||
assert first["url"] == f"https://jobnet.dk/find-job/{first['source_id']}"
|
||||
assert roskilde["url"].startswith("https://candidate.hr-manager.net/")
|
||||
|
||||
|
||||
def test_the_place_is_the_municipality_else_the_postal_district_else_none() -> None:
|
||||
first, taxi, metal, *_ = _rows(PLACES)
|
||||
assert first["places"] == [{"text": "Frederiksberg", "remote": None}]
|
||||
assert taxi["places"] == [{"text": "Gladsaxe", "remote": None}] # not Søborg
|
||||
assert (metal["places"], metal["location"]) == (
|
||||
[{"text": "Rødovre", "remote": None}], "Rødovre")
|
||||
german, aau = _rows(OTHER)
|
||||
assert (german["places"], aau["places"], aau["location"]) == ([], [], "")
|
||||
|
||||
|
||||
def test_the_country_is_danish_unless_the_ad_names_another() -> None:
|
||||
german, aau = _rows(OTHER)
|
||||
assert (german["country"], aau["country"]) == ("DE", "DK")
|
||||
assert german["url"].startswith("https://germantechjobs.de/")
|
||||
assert jobnet._country("") == "DK"
|
||||
assert jobnet._country("Norge") == "NO" and jobnet._country("Sweden") == "SE"
|
||||
assert jobnet._country("Atlantis") is None
|
||||
|
||||
|
||||
def test_the_deadline_is_kept_in_raw_and_1900_means_none() -> None:
|
||||
german, _aau = _rows(OTHER)
|
||||
assert german["applicationDeadline"] == "2027-01-02T00:00:00+01:00"
|
||||
ad = json.loads(OTHER)["jobAds"][0] | {"applicationDeadline": "1900-01-01T00:00:00+01:00"}
|
||||
[row] = jobnet.rows({"jobAds": [ad]}, "")
|
||||
assert "applicationDeadline" not in row
|
||||
|
||||
|
||||
def test_an_ad_without_an_id_or_a_title_is_skipped() -> None:
|
||||
ads = json.loads(OTHER)["jobAds"]
|
||||
assert jobnet.rows({"jobAds": [ads[0] | {"title": " "}, ads[1] | {"jobAdId": ""}]}, "") == []
|
||||
|
||||
|
||||
def test_it_sends_the_header_the_region_and_the_page_number() -> None:
|
||||
asked: list[tuple[str, dict[str, str]]] = []
|
||||
get = _stock(250, 250, asked)
|
||||
jobnet.page(get, "", None, Ask(params={"q": "data science", "region": "Midtjylland"}))
|
||||
jobnet.page(get, "", 2, Ask(params={"q": "data", "region": ""}))
|
||||
jobnet.page(get, "", None, Ask(query="head of AI", places=("Nordjylland",)))
|
||||
assert all(headers == {"x-csrf": "1"} for _url, headers in asked)
|
||||
assert parse_qs(urlsplit(asked[0][0]).query) == {
|
||||
"searchString": ["data science"], "orderType": ["PublicationDate"],
|
||||
"resultsPerPage": ["100"], "pageNumber": ["1"], "regions": ["Midtjylland"]}
|
||||
assert "regions" not in urlsplit(asked[1][0]).query and "pageNumber=2" in asked[1][0]
|
||||
assert "searchString=head+of+AI" in asked[2][0] and "regions=Nordjylland" in asked[2][0]
|
||||
assert urlsplit(asked[0][0]).netloc == "jobnet.dk"
|
||||
assert urlsplit(asked[0][0]).path == "/bff/FindJob/Search"
|
||||
|
||||
|
||||
def test_it_states_the_total_and_counts_the_ads_it_listed() -> None:
|
||||
_decoded, found, total, cursor = jobnet.page(
|
||||
lambda url, **kw: PLACES, "", None, Ask())
|
||||
assert total == 57 and len(found) == 6 and cursor is None # a short page ends it
|
||||
assert found[0]["id"] == _rows(PLACES)[0]["source_id"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("cursor", "stock", "after"), [
|
||||
(None, 250, 2), (2, 250, 3), (3, 250, None), # a short page is the end
|
||||
(99, 20000, 100), (100, 20000, None), # the ceiling: page 100 is the last
|
||||
])
|
||||
def test_it_pages_by_number_up_to_the_ceiling(
|
||||
cursor: int | None, stock: int, after: int | None) -> None:
|
||||
_decoded, _found, _total, nxt = jobnet.page(
|
||||
_stock(None, stock, []), "", cursor, Ask(params={"q": "x"}))
|
||||
assert nxt == after
|
||||
|
||||
|
||||
def test_the_page_past_the_last_is_empty_and_ends_the_read() -> None:
|
||||
decoded, found, total, nxt = jobnet.page(lambda url, **kw: END, "", 101, Ask())
|
||||
assert (found, total, nxt, jobnet.rows(decoded, "")) == ([], 20684, None, [])
|
||||
|
||||
|
||||
def test_an_answer_that_is_no_search_result_raises() -> None:
|
||||
with pytest.raises(ValueError, match="jobAds"):
|
||||
jobnet.page(lambda url, **kw: b'{"message": "denied"}', "", None, Ask())
|
||||
|
||||
|
||||
def test_it_refuses_an_unknown_region() -> None:
|
||||
with pytest.raises(ValueError, match="region"):
|
||||
jobnet.page(lambda url, **kw: b"{}", "", None,
|
||||
Ask(params={"q": "x", "region": "Skane"}))
|
||||
|
||||
|
||||
def test_the_regions_are_the_five_with_their_danish_labels() -> None:
|
||||
assert list(jobnet.REGIONS) == [
|
||||
"HovedstadenOgBornholm", "Midtjylland", "Syddanmark", "OevrigeSjaelland", "Nordjylland"]
|
||||
assert jobnet.REGIONS["OevrigeSjaelland"] == "Øvrige Sjælland"
|
||||
|
||||
|
||||
def test_saved_params_keep_a_region_or_none() -> None:
|
||||
assert jobnet.clean_params({"q": "x", "region": " Midtjylland "}) == {
|
||||
"q": "x", "region": "Midtjylland"}
|
||||
assert jobnet.clean_params({"q": "x"}) == {"q": "x", "region": ""}
|
||||
with pytest.raises(ValueError, match="region"):
|
||||
jobnet.clean_params({"q": "x", "region": "Skane"})
|
||||
Reference in new issue
Block a user