-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_consider.py
More file actions
58 lines (48 loc) · 2.17 KB
/
Copy pathtest_consider.py
File metadata and controls
58 lines (48 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Consider adapter tests (roadmap M4, ADR-0031).
Synthetic fixture matching the shape documented in the adapter's own module docstring — the
Consider search-jobs API's ``jobs`` array plus a ``meta`` search-after cursor object.
"""
from __future__ import annotations
from unittest.mock import patch
from openjobradar.poll.adapters import consider
def test_parses_representative_payload_attributing_the_employer_not_the_network() -> None:
data = {
"jobs": [
{
"jobId": "j1",
"title": "Data Scientist",
"companyName": "Greenfield Co",
"applyUrl": "https://apply.example.com/j1",
"locations": ["Boston, MA, USA"],
"remote": True,
"departments": ["Data"],
"timeStamp": "2026-01-02",
}
],
"meta": {},
}
with patch("openjobradar.poll.adapters.consider.post_json", return_value=data):
postings = consider.list_postings(
"greentown-labs|https://jobs.greentownlabs.com", "greentown-labs", "Greentown Labs"
)
assert len(postings) == 1
posting = postings[0]
# attribution goes to the EMPLOYER Consider reports, not the network board's own org_slug/org_name
assert posting.org_slug == "greenfield-co"
assert posting.org_name == "Greenfield Co"
assert posting.ats_type == "consider"
assert posting.job_id == "j1"
assert posting.title == "Data Scientist"
assert posting.apply_url == "https://apply.example.com/j1"
assert posting.location_raw == "Remote, US"
assert posting.department == "Data"
def test_malformed_board_id_missing_origin_returns_no_postings() -> None:
assert consider.list_postings("greentown-labs", "acme", "Acme") == []
assert consider.list_postings("", "acme", "Acme") == []
def test_detect_extracts_slug_and_origin() -> None:
html = '<script>window.__DATA__ = {"fixedBoard":"greentown-labs"}</script>'
assert (
consider.detect("https://jobs.greentownlabs.com/jobs", html)
== "greentown-labs|https://jobs.greentownlabs.com"
)
assert consider.detect("https://jobs.greentownlabs.com/jobs", "") is None