Skip to content

Commit 23212f1

Browse files
LEANDERANTONYclaude
andcommitted
CI round 2: fix the 5 tests broken by earlier commits' side effects
Two more side-effect breakages the first CI fix missed (the admin_refresh + JobReview type fixes were the only failures visible in the prior CI run; expanding the log on the new run surfaced these once the suite started running again). tests/test_jd_parser.py — 4 tests Hard-coded `static/demo_job_description/` paths broke when commit `facf822` ("Reorganize docs: SQL into docs/sql/, static + pdf_rendered into docs/") moved the fixture directory to `docs/static/demo_job_description/`. Production code is fine — `src/config.py:STATIC_DIR` was updated in the same commit and resolves to the new path. Only the test file's hard-coded literals were left behind. Fix: prepend `docs` to all four paths. tests/test_workday_job_source.py::test_adapter_paginates_until_max_or_total Test mocked 3 pages of 50 jobs each and asserted `len(fake.calls) == 3` because the old `_PAGE_SIZE = 50` made offset land at exactly `total = 150` after page 3. Commit `18fde26` ("Refresh worker: fix Workday 0-jobs + Ashby chunk timeouts") dropped `_PAGE_SIZE` to 20 to dodge Workday's tightened API limit, which broke the assertion math. Fix: derive page mock + assertion from the live `_PAGE_SIZE` constant. The test now works at any page size: pages_to_return * _PAGE_SIZE = total → exactly that many POSTs land before the offset == total early-stop trips. This way the next time Workday changes their limit and we bump `_PAGE_SIZE`, the test self-adjusts. Verified locally: 350/350 pytest pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7cd5b94 commit 23212f1

2 files changed

Lines changed: 33 additions & 21 deletions

File tree

tests/test_jd_parser.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_extract_job_details_finds_core_fields():
4444

4545

4646
def test_parse_jd_file_reads_pdf_fixture():
47-
sample_path = Path(__file__).resolve().parents[1] / "static" / "demo_job_description" / "Sample_Job_Description_MLEngineer.pdf"
47+
sample_path = Path(__file__).resolve().parents[1] / "docs" / "static" / "demo_job_description" / "Sample_Job_Description_MLEngineer.pdf"
4848

4949
with sample_path.open("rb") as handle:
5050
parsed = parse_jd_text(handle)
@@ -55,7 +55,7 @@ def test_parse_jd_file_reads_pdf_fixture():
5555

5656

5757
def test_parse_jd_file_reads_docx_fixture():
58-
sample_path = Path(__file__).resolve().parents[1] / "static" / "demo_job_description" / "Sample_Job_Description_DataAnalyst.docx"
58+
sample_path = Path(__file__).resolve().parents[1] / "docs" / "static" / "demo_job_description" / "Sample_Job_Description_DataAnalyst.docx"
5959

6060
with sample_path.open("rb") as handle:
6161
parsed = parse_jd_text(handle)
@@ -66,7 +66,7 @@ def test_parse_jd_file_reads_docx_fixture():
6666

6767

6868
def test_build_job_description_from_pdf_fixture_extracts_expected_signals():
69-
sample_path = Path(__file__).resolve().parents[1] / "static" / "demo_job_description" / "Sample_Job_Description_MLEngineer.pdf"
69+
sample_path = Path(__file__).resolve().parents[1] / "docs" / "static" / "demo_job_description" / "Sample_Job_Description_MLEngineer.pdf"
7070

7171
with sample_path.open("rb") as handle:
7272
parsed = parse_jd_text(handle)
@@ -81,7 +81,7 @@ def test_build_job_description_from_pdf_fixture_extracts_expected_signals():
8181

8282

8383
def test_build_job_description_from_docx_fixture_extracts_expected_signals():
84-
sample_path = Path(__file__).resolve().parents[1] / "static" / "demo_job_description" / "Sample_Job_Description_DataAnalyst.docx"
84+
sample_path = Path(__file__).resolve().parents[1] / "docs" / "static" / "demo_job_description" / "Sample_Job_Description_DataAnalyst.docx"
8585

8686
with sample_path.open("rb") as handle:
8787
parsed = parse_jd_text(handle)

tests/test_workday_job_source.py

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -179,24 +179,35 @@ def test_adapter_normalizes_workday_payload_to_jobposting():
179179

180180

181181
def test_adapter_paginates_until_max_or_total():
182-
"""Workday returns up to 50 per page; the adapter walks pages
183-
until it hits MAX_JOBS_PER_BOARD (250) OR the payload's total.
184-
Pin both: verify the right number of POSTs went out and the
185-
union of results came through."""
182+
"""The adapter walks pages until it hits MAX_JOBS_PER_BOARD OR the
183+
payload's `total`, whichever fires first. Pin both: verify the
184+
right number of POSTs went out and the union of results came
185+
through.
186+
187+
Test reads `_PAGE_SIZE` from the module instead of hard-coding so
188+
a later page-size change (e.g. when Workday tightens API limits
189+
again) doesn't re-break the test. We just need the math to land
190+
cleanly: PAGES_TO_RETURN pages × _PAGE_SIZE per page = total,
191+
so the early-stop hits exactly when `offset == total`.
192+
"""
193+
from src.job_sources.workday import _PAGE_SIZE
194+
186195
api_url = (
187196
"https://nvidia.wd5.myworkdayjobs.com/wday/cxs/"
188197
"nvidia/NVIDIAExternalCareerSite/jobs"
189198
)
190-
# Three pages of 50 each = 150 jobs total. Adapter should stop
191-
# after page 3 (4th page would be empty).
199+
200+
PAGES_TO_RETURN = 3
201+
total = _PAGE_SIZE * PAGES_TO_RETURN
192202
pages = [
193-
{"jobPostings": [_job_payload(req_id=f"R{i}", title=f"Job {i}") for i in range(50)],
194-
"total": 150},
195-
{"jobPostings": [_job_payload(req_id=f"R{50+i}", title=f"Job {50+i}") for i in range(50)],
196-
"total": 150},
197-
{"jobPostings": [_job_payload(req_id=f"R{100+i}", title=f"Job {100+i}") for i in range(50)],
198-
"total": 150},
199-
{"jobPostings": [], "total": 150}, # Should not be reached
203+
{
204+
"jobPostings": [
205+
_job_payload(req_id=f"R{p * _PAGE_SIZE + i}", title=f"Job {p * _PAGE_SIZE + i}")
206+
for i in range(_PAGE_SIZE)
207+
],
208+
"total": total,
209+
}
210+
for p in range(PAGES_TO_RETURN)
200211
]
201212
fake = _FakeSession({api_url: pages})
202213
adapter = WorkdayJobSourceAdapter(
@@ -207,10 +218,11 @@ def test_adapter_paginates_until_max_or_total():
207218
assert len(results) == 1
208219
label, status, postings = results[0]
209220
assert status == "ok"
210-
assert len(postings) == 150
211-
# 3 POST calls (the 4th empty page never reached because offset
212-
# 150 >= total 150 trips the early-stop condition).
213-
assert len(fake.calls) == 3
221+
assert len(postings) == total
222+
# PAGES_TO_RETURN POSTs — the next page never gets requested
223+
# because the offset == total early-stop trips immediately after
224+
# the last full page.
225+
assert len(fake.calls) == PAGES_TO_RETURN
214226

215227

216228
def test_adapter_unconfigured_returns_not_configured():

0 commit comments

Comments
 (0)