-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_workable.py
More file actions
69 lines (57 loc) · 2.36 KB
/
Copy pathtest_workable.py
File metadata and controls
69 lines (57 loc) · 2.36 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
"""Workable adapter (roadmap M4, ADR-0031)."""
from __future__ import annotations
from unittest.mock import patch
import pytest
from openjobradar.poll.adapters import workable
from openjobradar.poll.adapters.base import InvalidBoardIdError
def test_workable_parses_representative_payload_into_postings() -> None:
data = {
"name": "MyCo",
"jobs": [
{
"id": 999,
"shortcode": "ABCDE",
"title": "Data Scientist",
"city": "Berlin",
"country": "Germany",
"remote": True,
"description": "<p>Do science.</p>",
"requirements": "<p>Stats.</p>",
"department": "Data",
"published_on": "2026-02-02",
}
],
}
with patch("openjobradar.poll.adapters.workable.get_json", return_value=data):
postings = workable.list_postings("myco", "myco", "")
assert len(postings) == 1
posting = postings[0]
assert posting.org_slug == "myco"
assert posting.ats_type == "workable"
# adapter-specific: job_id prefers shortcode over numeric id
assert posting.job_id == "ABCDE"
assert posting.title == "Data Scientist"
assert posting.apply_url == "https://apply.workable.com/myco/j/ABCDE/"
assert posting.location_raw == "Berlin, Germany (remote)"
# account-level "name" fills org_name when the caller didn't pass one
assert posting.org_name == "MyCo"
def test_workable_apply_url_prefers_explicit_url_over_shortcode_fallback() -> None:
data = {
"jobs": [
{
"id": 1,
"shortcode": "X1",
"title": "Y",
"url": "https://apply.workable.com/myco/j/X1/custom/",
}
]
}
with patch("openjobradar.poll.adapters.workable.get_json", return_value=data):
postings = workable.list_postings("myco", "myco", "MyCo")
assert postings[0].apply_url == "https://apply.workable.com/myco/j/X1/custom/"
def test_workable_handles_empty_board() -> None:
with patch("openjobradar.poll.adapters.workable.get_json", return_value={"jobs": []}):
assert workable.list_postings("myco", "myco", "MyCo") == []
def test_workable_rejects_invalid_board_id() -> None:
with pytest.raises(InvalidBoardIdError):
workable.list_postings("has space", "myco", "MyCo")