-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_schoolspring.py
More file actions
71 lines (54 loc) · 2.58 KB
/
Copy pathtest_schoolspring.py
File metadata and controls
71 lines (54 loc) · 2.58 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
59
60
61
62
63
64
65
66
67
68
69
70
71
"""SchoolSpring adapter tests (roadmap M4, ADR-0031)."""
from __future__ import annotations
from unittest.mock import patch
import pytest
from openjobradar.poll.adapters import schoolspring
from openjobradar.poll.http import HttpError
_SEARCH_PAGE = {
"success": True,
"value": {
"jobsList": [
{
"jobId": 555,
"title": "Math Teacher",
"location": "Main Campus",
"employer": "Central High School",
"displayDate": "2026-01-01T00:00:00",
}
]
},
}
_EMPTY_PAGE = {"success": True, "value": {"jobsList": []}}
_BRAND_FOUND = {"success": True, "value": {"id": 42, "orgName": "Acme Unified"}}
_BRAND_MISSING = {"success": True, "value": {"id": 0, "orgName": ""}}
def test_parses_representative_payload_into_postings() -> None:
with patch("openjobradar.poll.adapters.schoolspring.get_json", return_value=_SEARCH_PAGE):
postings = schoolspring.list_postings("acmeunified", "acme-unified", "Acme Unified")
assert len(postings) == 1
posting = postings[0]
assert posting.org_slug == "acme-unified"
assert posting.ats_type == "schoolspring"
assert posting.job_id == "555"
assert posting.title == "Math Teacher"
assert posting.department == "Central High School"
assert posting.apply_url == "https://acmeunified.schoolspring.com/jobdetail?jobId=555"
def test_zero_jobs_with_real_district_returns_empty() -> None:
def fake_get_json(url: str, **kwargs: object) -> dict:
return _BRAND_FOUND if "Brands" in url else _EMPTY_PAGE
with patch("openjobradar.poll.adapters.schoolspring.get_json", side_effect=fake_get_json):
assert schoolspring.list_postings("acmeunified", "acme-unified", "Acme Unified") == []
def test_zero_jobs_with_unknown_district_raises() -> None:
def fake_get_json(url: str, **kwargs: object) -> dict:
return _BRAND_MISSING if "Brands" in url else _EMPTY_PAGE
with (
patch("openjobradar.poll.adapters.schoolspring.get_json", side_effect=fake_get_json),
pytest.raises(HttpError),
):
schoolspring.list_postings("nosuchdistrict", "acme-unified", "Acme Unified")
def test_rejects_invalid_board_id() -> None:
with pytest.raises(ValueError):
schoolspring.list_postings("has space", "acme", "Acme")
def test_detect_accepts_both_hostnames() -> None:
assert schoolspring.detect("https://acmeunified.schoolspring.com/") == "acmeunified"
assert schoolspring.detect("https://acmeunified.tedk12.com/") == "acmeunified"
assert schoolspring.detect("https://example.com") is None