返回 last30days-skill
test_jobs_platform_boards.py
根目录 / tests / test_jobs_platform_boards.py
1 """Job boards found by the hiring platform a careers page runs on.
2
3 The lane reads a large company's board by detecting its platform off the
4 careers page (Oracle Recruiting Cloud, Phenom, Jibe, TalentBrew, Eightfold)
5 rather than from a hand-written list of companies. A board whose reader fails
6 falls to the site's job sitemap and then to the web tier, and the run says
7 which happened. Fixtures in ``fixtures/jobs_platforms.json`` are trimmed live
8 answers recorded on 2026-11-14 (Kula's on 2026-11-16).
9 """
10
11 from __future__ import annotations
12
13 import copy
14 import json
15 from pathlib import Path
16 from unittest.mock import patch
17
18 import pytest
19
20 from lib import health, http, jobs, render
21 from lib.job_boards import detect, google, ibm, jibe, kula, oracle, phenom, robots, sitemap, talentbrew
22
23 from tests.test_render_patents import _report
24
25 WINDOW = ("2026-10-15", "2026-11-14")
26 # The real resolver, kept before the autouse fixture stubs it.
27 _REAL_RESOLVES_PUBLIC = sitemap._resolves_public
28 FX = json.loads((Path(__file__).parent / "fixtures" / "jobs_platforms.json").read_text(encoding="utf-8"))
29
30 # Careers-page markup as each platform serves it (trimmed from the live pages).
31 ORACLE_DELL_PAGE = (
32 '<base href="/hcmUI/CandidateExperience/en/sites/careers" '
33 'data-apibaseurl="https://enterpriseplatform.dell.com:443" data-fahosturl="" '
34 'data-vanitybaseurl="" data-sitenumber="CX_1001">'
35 '<link rel="icon" href="/hcmRestApi/CandidateExperience/siteFavicon/favicon-16x16.png?siteNumber=CX_1001">'
36 )
37 ORACLE_JPMC_PAGE = (
38 '<a href="https://jpmc.fa.oraclecloud.com/hcmUI/CandidateExperience/en/sites/CX_1001/requisitions">'
39 "Search jobs</a><p>Join our team</p>"
40 )
41 ORACLE_OWN_PAGE = (
42 '<link rel="icon" href="https://eeho.fa.us2.oraclecloud.com:443/hcmRestApi/CandidateExperience/'
43 'siteFavicon/favicon-16x16.png?siteNumber=CX_45001&size=16x16">'
44 )
45 PHENOM_PAGE = (
46 '<script src="https://cdn.phenompeople.com/CareerConnectResources/x.js"></script>'
47 '<script>phApp.ddo = {"siteConfig": {}}; var x = {"baseUrl":"https://careers.cisco.com/global/en/"};</script>'
48 )
49 JIBE_PAGE = (
50 '<link rel="canonical" href="https://careers.amd.com/careers-home/jobs" />'
51 '<script src="https://assets.jibecdn.com/prod/amd/0.0.83/assets/app.js"></script>'
52 )
53 TALENTBREW_PAGE = (
54 '<img src="https://tbcdn.talentbrew.com/company/185/v3_0/img/logo.svg">'
55 '<form action="/search-jobs" method="get"></form>'
56 )
57
58
59 @pytest.fixture(autouse=True)
60 def _fresh_robots(monkeypatch):
61 robots.clear_cache()
62 # Tests never resolve names: a name resolves to a public address unless
63 # it is one a test marks as internal.
64 monkeypatch.setattr(sitemap, "_resolves_public", lambda name: "internal" not in name)
65 yield
66 robots.clear_cache()
67
68
69 # --- detection ------------------------------------------------------------------
70
71
72 @pytest.mark.parametrize(
73 ("html", "url", "expected"),
74 [
75 (ORACLE_DELL_PAGE, "https://enterpriseplatform.dell.com/hcmUI/CandidateExperience/en/sites/careers",
76 ("oracle", {"board": "enterpriseplatform.dell.com", "site_number": "CX_1001"})),
77 (ORACLE_JPMC_PAGE, "https://www.jpmorganchase.com/careers",
78 ("oracle", {"board": "jpmc.fa.oraclecloud.com", "site_number": "CX_1001"})),
79 (ORACLE_OWN_PAGE, "https://careers.oracle.com/en/sites/jobsearch",
80 ("oracle", {"board": "eeho.fa.us2.oraclecloud.com", "site_number": "CX_45001"})),
81 (PHENOM_PAGE, "https://careers.cisco.com/global/en",
82 ("phenom", {"board": "careers.cisco.com", "country": "global", "lang": "en",
83 "base_url": "https://careers.cisco.com/global/en/"})),
84 (JIBE_PAGE, "https://careers.amd.com/careers-home/jobs",
85 ("jibe", {"board": "careers.amd.com", "jobs_path": "/careers-home/jobs"})),
86 (TALENTBREW_PAGE, "https://jobs.boeing.com/", ("talentbrew", {"board": "jobs.boeing.com"})),
87 ('<link href="https://static.vscdn.net/fonts/css/eightfold-font-base.css">'
88 '<script>window._EF_GROUP_ID = "netflix.com";</script>',
89 "https://explore.jobs.netflix.net/careers",
90 ("eightfold", {"board": "explore.jobs.netflix.net", "domain": "netflix.com"})),
91 ('<a href="https://careers.kula.ai/initech">Open roles</a>', "https://initech.com/careers",
92 ("kula", {"board": "careers.kula.ai", "slug": "initech"})),
93 ],
94 )
95 def test_a_platform_is_read_off_the_careers_page(html, url, expected):
96 provider, entry = detect.detect_platform(html, url)
97 assert (provider, {key: value for key, value in entry.items() if key != "provider"}) == expected
98
99
100 def test_a_page_with_no_platform_markup_names_none():
101 assert detect.detect_platform("<p>Open positions at Initech</p>", "https://initech.com/careers") is None
102 # A TalentBrew asset on a page that is not the job search is not the board.
103 assert detect.detect_platform(
104 '<img src="https://tbcdn.talentbrew.com/a.svg">', "https://example.com/",
105 ) is None
106
107
108 def test_microsoft_s_landing_page_points_at_its_eightfold_board():
109 html = '<div id="careers-eightFoldCareerUrl" hidden>https://apply.careers.microsoft.com/careers</div>'
110 assert detect.eightfold_career_url(html) == "https://apply.careers.microsoft.com/careers"
111
112
113 # --- parsers --------------------------------------------------------------------
114
115 ORACLE_ENTRY = {"name": "JPMorgan", "provider": "oracle", "board": "jpmc.fa.oraclecloud.com",
116 "site_number": "CX_1001"}
117
118
119 def test_an_oracle_page_parses_to_rows_with_true_posted_dates_and_detail_urls():
120 items, total = oracle.parse_listing(FX["oracle_list"], ORACLE_ENTRY)
121 assert total == 6972 and len(items) == 5
122 first = items[0]
123 assert first["title"] == "Python Java AWS Software Engineer III (ML) - Agentic Treasury"
124 assert first["url"] == (
125 "https://jpmc.fa.oraclecloud.com/hcmUI/CandidateExperience/en/sites/CX_1001/job/210777835"
126 )
127 assert first["posted_date_true"] and first["date"] == "2026-11-14"
128 assert first["provider"] == "oracle" and first["id"] == "OR210777835"
129 assert 'finder=ById;Id="210777835",siteNumber=CX_1001' in first["detail_url"]
130
131
132 def test_an_oracle_answer_without_a_requisition_list_is_a_shape_error():
133 with pytest.raises(jobs.BoardShapeError):
134 oracle.parse_listing({"items": [{"TotalJobsCount": 3}]}, ORACLE_ENTRY)
135
136
137 def test_a_jibe_page_parses_to_rows_with_their_full_text():
138 items, total = jibe.parse_listing(FX["jibe_list"], {"board": "careers.amd.com", "jobs_path": "/careers-home/jobs"})
139 assert total == 1312 and len(items) == 3
140 first = items[0]
141 assert first["title"] == "Sr. Channel Marketing Specialist"
142 assert first["url"] == "https://careers.amd.com/careers-home/jobs/95802"
143 assert first["department"] == "Sales / Marketing"
144 assert first["posted_date_true"] and first["date"] == "2026-11-14"
145 assert first["description"]
146
147
148 def test_a_phenom_page_parses_to_rows_with_every_location():
149 entry = {"board": "careers.cisco.com", "base_url": "https://careers.cisco.com/global/en/"}
150 items, total = phenom.parse_listing(FX["phenom_list"], entry)
151 assert total == FX["phenom_list"]["refineSearch"]["totalHits"] and len(items) == 3
152 first = items[0]
153 assert first["url"].startswith("https://careers.cisco.com/global/en/job/")
154 assert first["locations"] and first["posted_date_true"]
155
156
157 def test_the_phenom_role_page_text_is_read_from_its_page_object():
158 page = '<script>phApp.ddo = {"jobDetail": {"data": {"job": {"description": "<p>Own the router.</p>"}}}};</script>'
159 assert phenom.page_object(page)["jobDetail"]["data"]["job"]["description"] == "<p>Own the router.</p>"
160 item = {"url": "https://careers.cisco.com/global/en/job/1"}
161 with patch.object(phenom.http, "get_text", return_value=page):
162 assert phenom.fetch_details([item], deadline=jobs.time.monotonic() + 5) == (0, 0)
163 assert item["description"] == "Own the router."
164
165
166 def test_a_talentbrew_results_page_parses_links_locations_and_dates():
167 items, total = talentbrew.parse_listing(FX["talentbrew_list"], {"board": "jobs.boeing.com"})
168 assert total == 1130 and len(items) == 3
169 first = items[0]
170 assert first["url"].startswith("https://jobs.boeing.com/job/")
171 assert first["title"] and first["location"]
172 assert first["date"] and first["posted_date_true"]
173
174
175 def test_talentbrew_role_text_comes_from_the_role_page_jobposting():
176 page = ('<script type="application/ld+json">{"@type": "JobPosting", "title": "Engineer", '
177 '"description": "&lt;p&gt;Build the 777X wing.&lt;/p&gt;"}</script>')
178 assert jobs.jsonld_role_text(page) == ("Build the 777X wing.", "Build the 777X wing.")
179 assert jobs.jsonld_role_text("<p>no posting</p>") is None
180
181
182 def test_a_google_results_page_parses_twenty_role_rows_and_claims_no_posted_date():
183 items, total = google.parse_listing(FX["google_page"])
184 assert total == 3149 and len(items) == 3
185 first = items[0]
186 assert first["title"] == "Senior Software Engineer, Cloud AI/ML Infrastructure"
187 assert first["url"].startswith(google.RESULTS_URL + "120081008824328902-senior-software-engineer")
188 assert first["description"] and first["location"]
189 assert not any(item["posted_date_true"] or item["date"] for item in items)
190
191
192 def test_an_ibm_search_page_parses_to_rows():
193 items, total = ibm.parse_listing(FX["ibm_list"])
194 assert total == 3561 and len(items) == 3
195 assert items[0]["url"].startswith("https://careers.ibm.com/careers/JobDetail?jobId=")
196 assert not items[0]["posted_date_true"]
197
198
199 # --- the paged read -------------------------------------------------------------
200
201
202 def _pages(total, page_size, *, fail_at=None):
203 asked = []
204
205 def page(offset):
206 def call(_deadline):
207 asked.append(offset)
208 if fail_at is not None and offset == fail_at:
209 raise http.HTTPError("HTTP 429", status_code=429)
210 rows = [
211 {"id": f"r{n}", "title": f"Role {n}", "date": "2026-11-01"}
212 for n in range(offset, min(offset + page_size, total))
213 ]
214 return {"rows": rows, "total": total}
215 return call
216
217 def parse(payload):
218 return list(payload["rows"]), payload["total"]
219
220 return asked, page, parse
221
222
223 def test_a_board_of_several_thousand_rows_is_read_whole_not_stopped_at_the_window():
224 asked, page, parse = _pages(6000, 200)
225 items, info = jobs._read_newest_first(
226 page, parse, page_size=200, row_ceiling=7000, window_start="2026-10-15",
227 deadline=jobs.time.monotonic() + 30,
228 )
229 assert len(items) == 6000 and len(asked) == 30
230 assert not info["board_cut_short"] and info["board_window_covered"]
231
232
233 def test_no_page_after_a_failed_one_is_kept_and_the_earlier_pages_all_are():
234 asked, page, parse = _pages(2000, 100, fail_at=1000)
235 items, info = jobs._read_newest_first(
236 page, parse, page_size=100, row_ceiling=7000, window_start=None,
237 deadline=jobs.time.monotonic() + 30, workers=4,
238 )
239 assert [row["id"] for row in items] == [f"r{n}" for n in range(1000)]
240 assert info["board_cut_short"]
241 # Paging stops after the failed page: at most the pages already in flight.
242 assert max(asked) <= 1000 + 4 * 100
243
244
245 def test_a_board_that_serves_fewer_rows_a_page_than_asked_is_read_in_part():
246 # Asked for 500 a page, the server caps at 100: every page answers, and
247 # 400 of 2,000 rows are read. That is a board read in part.
248 def page(offset):
249 def call(_deadline):
250 rows = [{"id": f"r{n}", "title": f"Role {n}"} for n in range(offset, min(offset + 100, 2000))]
251 return {"rows": rows, "total": 2000}
252 return call
253
254 items, info = jobs._read_newest_first(
255 page, lambda payload: (payload["rows"], payload["total"]), page_size=500,
256 row_ceiling=7000, window_start=None, deadline=jobs.time.monotonic() + 30,
257 newest_first=False,
258 )
259 assert len(items) == 400
260 assert info["board_cut_short"] and not info["board_window_covered"]
261
262
263 def test_a_board_not_sorted_by_date_covers_the_window_only_when_read_whole():
264 asked, page, parse = _pages(300, 100, fail_at=200)
265 _items, info = jobs._read_newest_first(
266 page, parse, page_size=100, row_ceiling=7000, window_start="2026-11-05",
267 deadline=jobs.time.monotonic() + 30, newest_first=False,
268 )
269 # Rows older than the window were read, but in no date order: not covered.
270 assert info["board_window_covered"] is False
271 assert jobs._board_counts(_items, info, WINDOW)["new_in_window"] is None
272
273
274 # --- search flows ---------------------------------------------------------------
275
276
277 class _Site:
278 """Answers the lane's requests from a table; anything else is a 404."""
279
280 def __init__(self, texts=None, gets=None, posts=None):
281 self.texts, self.gets, self.posts = texts or {}, gets or {}, posts or {}
282 self.asked = []
283 # Requested URL -> the address that answered it.
284 self.redirects: dict[str, str] = {}
285
286 def _match(self, table, url):
287 for key, answer in table.items():
288 if url == key or (key.endswith("*") and url.startswith(key[:-1])):
289 return answer(url) if callable(answer) else answer
290 return None
291
292 def text(self, url, *_args, **kwargs):
293 self.asked.append(url)
294 found = self._match(self.texts, url)
295 if isinstance(found, Exception):
296 raise found
297 if found is not None and kwargs.get("landed") is not None:
298 kwargs["landed"].append(self.redirects.get(url, url))
299 return found
300
301 def get(self, url, *_args, **_kwargs):
302 self.asked.append(url)
303 found = self._match(self.gets, url)
304 if isinstance(found, Exception):
305 raise found
306 if found is None:
307 raise http.HTTPError("HTTP 404: Not Found", status_code=404)
308 return copy.deepcopy(found)
309
310 def post(self, url, *_args, **_kwargs):
311 self.asked.append(url)
312 found = self._match(self.posts, url)
313 if found is None:
314 raise http.HTTPError("HTTP 404: Not Found", status_code=404)
315 return copy.deepcopy(found)
316
317
318 def _run(company, site, fake, **kwargs):
319 with patch.object(jobs.http, "get_text", side_effect=fake.text), \
320 patch.object(jobs.http, "get", side_effect=fake.get), \
321 patch.object(jobs.http, "post", side_effect=fake.post):
322 return jobs.search_jobs(company, WINDOW, {}, web_backend="none", site=site, **kwargs)
323
324
325 def _oracle_listing(url):
326 # The recorded page is the first; the board ends after it.
327 if "offset=0," in url:
328 return FX["oracle_list"]
329 return {"items": [{"TotalJobsCount": 6972, "requisitionList": []}]}
330
331
332 def _oracle_detail(url):
333 # Each role gets a sentence of its own, so it survives boilerplate removal.
334 ident = url.split('Id="', 1)[1].split('"', 1)[0]
335 answer = copy.deepcopy(FX["oracle_detail"])
336 role = answer["items"][0]
337 role["ExternalDescriptionStr"] = f"<p>Own requisition {ident}.</p>" + role["ExternalDescriptionStr"]
338 return answer
339
340
341 def _oracle_site():
342 return _Site(
343 texts={"https://www.jpmorganchase.com/careers": ORACLE_JPMC_PAGE},
344 gets={
345 "https://jpmc.fa.oraclecloud.com/hcmRestApi/resources/latest/recruitingCEJobRequisitions?*":
346 _oracle_listing,
347 "https://jpmc.fa.oraclecloud.com/hcmRestApi/resources/latest/recruitingCEJobRequisitionDetails?*":
348 _oracle_detail,
349 },
350 )
351
352
353 def test_an_oracle_board_named_by_the_careers_page_prints_a_digest_with_role_text():
354 fake = _oracle_site()
355 items, artifact = _run("JPMorgan", "https://www.jpmorganchase.com/", fake)
356 assert artifact["tier"] == "ats" and artifact["provider"] == "oracle"
357 assert artifact["owned"] and artifact["found_via"] == "site"
358 assert artifact["open_roles"] == 6972
359 assert len(items) == 5
360 roles = artifact["digest"]["roles"]
361 assert roles and all("Own requisition" in role["text"] for role in roles)
362 assert sum(1 for url in fake.asked if "RequisitionDetails" in url) == len(roles)
363 rendered = render.render_compact(_report(jobs=artifact))
364 assert "\n## Jobs Digest\n" in rendered and "💼 Jobs: 6,972 open roles" in rendered
365
366
367 def test_with_respect_robots_on_a_disallowed_listing_is_not_read(monkeypatch):
368 monkeypatch.setenv(robots.RESPECT_ROBOTS_VAR, "1")
369 fake = _oracle_site()
370 fake.texts["https://jpmc.fa.oraclecloud.com/robots.txt"] = "User-agent: *\nDisallow: /hcmRestApi/\n"
371 _items, artifact = _run("JPMorgan", "https://www.jpmorganchase.com/", fake)
372 assert not any("recruitingCEJobRequisitions" in url for url in fake.asked)
373 assert artifact["job_site_unreadable"] == "JPMorgan"
374 assert artifact["job_site_unreadable_reason"] == jobs.ROBOTS_REASON
375
376
377 def test_with_respect_robots_off_no_robots_txt_is_asked_before_a_listing():
378 fake = _oracle_site()
379 _run("JPMorgan", "https://www.jpmorganchase.com/", fake)
380 assert not any(url.endswith("/robots.txt") for url in fake.asked)
381
382
383 def test_a_platform_reader_that_fails_falls_to_the_site_s_job_sitemap():
384 fake = _oracle_site()
385 fake.gets = {} # every listing call is a 404
386 fake.texts.update({
387 "https://jobs.jpmorganchase.com/robots.txt": FX["sap_robots"].replace("jobs.sap.com", "jobs.jpmorganchase.com"),
388 "https://jobs.jpmorganchase.com/sitemap.xml": FX["sap_index"].replace("jobs.sap.com", "jobs.jpmorganchase.com"),
389 "https://jobs.jpmorganchase.com/en/jobs/sitemap.xml": FX["sap_sitemap"].replace("jobs.sap.com", "jobs.jpmorganchase.com"),
390 })
391 items, artifact = _run("JPMorgan", "https://www.jpmorganchase.com/", fake)
392 assert artifact["provider"] == "sitemap" and artifact["titles_only"]
393 assert "oracle board not read" in artifact["board_fallback"]
394 assert artifact["digest"]["titles_only"] and "oracle board not read" in artifact["digest"]["note"]
395 assert items[0]["title"] == "Sap Success Plan Manager Expert South"
396 assert artifact["new_in_window"] is None
397 # The footer says the run fell to the sitemap, and why.
398 footer = render._jobs_board_footer_line(_report(jobs=artifact))
399 assert "from its job sitemap (oracle board not read:" in footer
400
401
402 def test_a_platform_reader_that_fails_with_no_sitemap_says_the_site_cannot_be_read(capsys):
403 fake = _oracle_site()
404 fake.gets = {}
405 items, artifact = _run("JPMorgan", "https://www.jpmorganchase.com/", fake)
406 assert items == [] and artifact["tier"] == "web"
407 assert artifact["job_site_unreadable"] == "JPMorgan"
408 assert "oracle board answered with an error" in artifact["job_site_unreadable_reason"]
409 assert "JPMorgan's job site can't be read automatically" in capsys.readouterr().err
410 report = _report()
411 report.artifacts["jobs_site_unreadable"] = artifact["job_site_unreadable"]
412 report.artifacts["jobs_site_unreadable_reason"] = artifact["job_site_unreadable_reason"]
413 assert "(its oracle board answered with an error" in render.render_compact(report)
414
415
416 def test_a_walled_careers_site_is_read_from_its_job_sitemap():
417 fake = _Site(texts={
418 "https://jobs.sap.com/robots.txt": FX["sap_robots"],
419 "https://jobs.sap.com/sitemap.xml": FX["sap_index"],
420 # The site's general sitemap answers with no role pages.
421 "https://jobs.sap.com/en/sitemap.xml": "<urlset></urlset>",
422 "https://jobs.sap.com/en/jobs/sitemap.xml": FX["sap_sitemap"],
423 })
424 items, artifact = _run("SAP", "https://www.sap.com/", fake)
425 # The site's own careers and jobs hosts were tried before the sitemap.
426 assert "https://careers.sap.com/" in fake.asked and "https://jobs.sap.com/" in fake.asked
427 assert artifact["provider"] == "sitemap" and artifact["owned"]
428 assert artifact["open_roles"] == 6 and len(items) == 6
429 rendered = render.render_compact(_report(jobs=artifact))
430 assert "\n## Jobs Digest\n" in rendered and "titles only" in rendered
431 assert "💼 Jobs: 6 open roles │ from its job sitemap" in rendered
432
433
434 def test_sitemap_urls_with_no_title_take_it_from_the_role_page():
435 urlset = ('<urlset><url><loc>https://careers.walmart.com/us/en/jobs/R-674391</loc></url>'
436 '<url><loc>https://careers.walmart.com/us/en/jobs/R-674392</loc></url></urlset>')
437 fake = _Site(texts={
438 "https://careers.walmart.com/robots.txt": "User-agent: *\nDisallow: /api\nSitemap: https://careers.walmart.com/sitemap.xml\n",
439 "https://careers.walmart.com/sitemap.xml": urlset,
440 "https://careers.walmart.com/us/en/jobs/R-674391":
441 '<meta property=og:title content="Prepared Meals Associate - Walmart Careers" />',
442 })
443 items, artifact = _run("Walmart", "https://www.walmart.com/", fake)
444 assert [item["title"] for item in items] == ["Prepared Meals Associate"]
445 assert artifact["open_roles"] == 2 and artifact["board_titles_from_pages"]
446
447
448 def test_a_sitemap_whose_role_pages_are_walled_gives_a_count_and_no_digest():
449 urlset = '<urlset><url><loc>https://jobs.uber.com/en/jobs/149574/</loc></url></urlset>'
450 fake = _Site(texts={
451 "https://jobs.uber.com/robots.txt": "User-Agent: *\nSitemap: https://jobs.uber.com/sitemap.xml\n",
452 "https://jobs.uber.com/sitemap.xml": urlset,
453 })
454 items, artifact = _run("Uber", "https://www.uber.com/", fake)
455 assert items == [] and artifact["open_roles"] == 1 and "digest" not in artifact
456 footer = render._jobs_board_footer_line(_report(jobs=artifact))
457 assert footer == "💼 Jobs: 1 open role │ from its job sitemap, no titles readable"
458
459
460 def test_the_sitemap_title_rules():
461 assert sitemap.title_from_url("https://jobs.sap.com/en/jobs/744000161572239/sap-success-plan-manager-west/") == \
462 "Sap Success Plan Manager West"
463 assert sitemap.title_from_url(
464 "https://intel.wd1.myworkdayjobs.com/External/job/US-Oregon-Hillsboro/XMLNAME-RF-Lab-Engineer_JR0288778"
465 ) == "RF Lab Engineer"
466 assert sitemap.title_from_url("https://jobs.uber.com/en/jobs/149574/") == ""
467 assert sitemap.title_from_page("<title>Data Engineer | Acme Careers</title>", "Acme") == "Data Engineer"
468
469
470 def test_google_is_read_a_few_pages_at_low_concurrency_and_prints_no_new_count():
471 pages = []
472
473 def page(url):
474 pages.append(url)
475 return FX["google_page"]
476
477 fake = _Site(texts={google.RESULTS_URL + "?sort_by=date&page=*": page})
478 with patch.object(google, "PAGE_LIMIT", 4):
479 items, artifact = _run("Google", "https://www.google.com/", fake)
480 assert artifact["provider"] == "google" and artifact["open_roles"] == 3149
481 assert len(pages) == 4 and artifact["new_in_window"] is None
482 assert not any("/careers" == url[-8:] for url in fake.asked)
483 assert google.WORKERS <= 2
484
485
486 def test_google_with_respect_robots_on_is_not_read(monkeypatch):
487 monkeypatch.setenv(robots.RESPECT_ROBOTS_VAR, "1")
488 fake = _Site(texts={
489 "https://www.google.com/robots.txt": "User-agent: *\nDisallow: /about/careers/applications/jobs/results\n",
490 })
491 items, artifact = _run("Google", "https://www.google.com/", fake)
492 assert items == [] and artifact["job_site_unreadable"] == "Google"
493 assert artifact["job_site_unreadable_reason"] == jobs.ROBOTS_REASON
494 assert not any("jobs/results/?" in url for url in fake.asked)
495
496
497 def test_disney_s_careers_page_on_its_own_domain_is_read_through_phenom():
498 page = PHENOM_PAGE.replace("careers.cisco.com/global/en/", "join.disneycareers.com/global/en/")
499 fake = _Site(
500 texts={"https://join.disneycareers.com/global/en": page},
501 posts={"https://join.disneycareers.com/widgets": FX["phenom_list"]},
502 )
503 _items, artifact = _run("Disney", "https://disney.com/", fake)
504 assert artifact["provider"] == "phenom" and artifact["owned"]
505 assert artifact["board_token"] == "join.disneycareers.com"
506
507
508 def test_a_careers_page_that_redirects_off_site_to_a_search_engine_is_not_read():
509 budget = jobs.LaneBudget()
510 token = jobs._BUDGET.set(budget)
511 try:
512 budget.landed["https://www.microsoft.com/careers"] = "https://www.bing.com/?ref=aka"
513 with patch.object(jobs.http, "get_text", return_value="<p>Open positions</p>"):
514 page, _gone, _used = jobs._careers_page_at(
515 "https://www.microsoft.com/careers", guessed=True, company="Microsoft",
516 site="https://www.microsoft.com/",
517 )
518 finally:
519 jobs._BUDGET.reset(token)
520 assert page is None
521
522
523 def test_get_text_reports_the_address_that_answered():
524 headers = http.ResponseHeaders({})
525 headers.url = "https://jobs.boeing.com/"
526 landed = []
527 with patch.object(http, "request", return_value=("<html></html>", headers)):
528 assert http.get_text("https://www.boeing.com/careers", landed=landed) == "<html></html>"
529 assert landed == ["https://jobs.boeing.com/"]
530
531
532 # --- robots.txt -----------------------------------------------------------------
533
534
535 def test_robots_rules_use_wildcards_and_the_longest_match():
536 rules = robots.Rules(
537 "User-agent: Googlebot\nDisallow: /\n\nUser-agent: *\nDisallow: /search-jobs/\n"
538 "Allow: /search-jobs/public$\nDisallow: /*?q=\nSitemap: https://x.com/sitemap.xml\n"
539 )
540 assert not rules.allows("/search-jobs/results?CurrentPage=1")
541 assert rules.allows("/search-jobs/public")
542 assert not rules.allows("/en/jobs?q=engineer")
543 assert rules.allows("/job/123")
544 assert rules.sitemaps == ["https://x.com/sitemap.xml"]
545
546
547 def test_robots_is_never_asked_with_the_setting_off(monkeypatch):
548 monkeypatch.delenv(robots.RESPECT_ROBOTS_VAR, raising=False)
549 with patch.object(robots.http, "get_text", side_effect=AssertionError("asked")):
550 assert robots.disallowed("https://www.google.com/about/careers/applications/jobs/results/") is False
551
552
553 def test_a_jibe_board_one_link_past_the_careers_page_is_read_newest_first():
554 landing = '<a href="https://careers.amd.com/careers-home/jobs">Search jobs</a><p>Join our team</p>'
555
556 def listing(url):
557 return FX["jibe_list"] if "page=1&" in url else {"totalCount": 1312, "jobs": []}
558
559 fake = _Site(
560 texts={"https://www.amd.com/careers": landing, "https://careers.amd.com/careers-home/jobs": JIBE_PAGE},
561 gets={"https://careers.amd.com/api/jobs?*": listing},
562 )
563 items, artifact = _run("AMD", "https://www.amd.com/", fake)
564 assert artifact["provider"] == "jibe" and artifact["owned"] and artifact["found_via"] == "site"
565 assert len(items) == 3 and artifact["open_roles"] == 1312
566 assert artifact["digest"]["roles"]
567
568
569 def test_a_talentbrew_board_is_read_and_its_role_text_comes_from_the_role_pages():
570 def role_page(url):
571 return ('<script type="application/ld+json">{"@type": "JobPosting", "title": "x", '
572 f'"description": "Build a wing for role {url.rsplit("/", 1)[-1]}."}}</script>')
573
574 def listing(url):
575 return FX["talentbrew_list"] if "CurrentPage=1&" in url else {"results": "<ul></ul>"}
576
577 fake = _Site(
578 texts={"https://www.boeing.com/careers": TALENTBREW_PAGE, "https://jobs.boeing.com/job/*": role_page},
579 gets={"https://jobs.boeing.com/search-jobs/results?*": listing},
580 )
581 fake.redirects = {"https://www.boeing.com/careers": "https://jobs.boeing.com/"}
582 # The careers page redirects to the job search on its jobs host.
583 _items, artifact = _run("Boeing", "https://www.boeing.com/", fake)
584 assert artifact["provider"] == "talentbrew" and artifact["board_token"] == "jobs.boeing.com"
585 assert artifact["open_roles"] == 1130
586 assert all("Build a wing" in role["text"] for role in artifact["digest"]["roles"])
587
588
589 def test_ibm_is_read_through_its_search_api():
590 calls = []
591
592 def post(url, body, *_args, **_kwargs):
593 calls.append(body["from"])
594 answer = copy.deepcopy(FX["ibm_list"])
595 if body["from"]:
596 answer["hits"]["hits"] = []
597 return answer
598
599 fake = _Site()
600 with patch.object(jobs.http, "get_text", side_effect=fake.text), \
601 patch.object(jobs.http, "get", side_effect=fake.get), \
602 patch.object(jobs.http, "post", side_effect=post):
603 items, artifact = jobs.search_jobs("IBM", WINDOW, {}, web_backend="none", site="https://www.ibm.com/")
604 assert artifact["provider"] == "ibm" and artifact["open_roles"] == 3561
605 assert len(items) == 3 and 0 in calls
606 assert artifact["new_in_window"] is None
607
608
609 # --- review fixes ----------------------------------------------------------------
610
611
612 def test_a_platform_page_on_a_guessed_domain_is_not_read_as_the_company_s_board():
613 # No official site: mercury.com is guessed from the name and may be
614 # another business's. Its Oracle page names no company, so it is not read.
615 fake = _Site(texts={
616 "https://mercury.com/careers*": ORACLE_JPMC_PAGE,
617 "https://www.mercury.com/careers*": ORACLE_JPMC_PAGE,
618 })
619 _items, artifact = _run("Mercury", "", fake)
620 assert not any("oraclecloud.com" in url for url in fake.asked)
621 assert artifact.get("provider") != "oracle"
622
623
624 def test_a_company_reader_that_raises_a_value_error_falls_through_not_over():
625 fake = _oracle_site()
626 with patch.object(oracle, "read_board", side_effect=ValueError("bad JSON")):
627 items, artifact = _run("JPMorgan", "https://www.jpmorganchase.com/", fake)
628 assert items == [] and artifact["job_site_unreadable"] == "JPMorgan"
629
630
631 def test_a_sitemap_that_is_not_text_costs_only_itself():
632 robots_txt = ("User-agent: *\nSitemap: https://jobs.sap.com/jobs.xml.gz\n"
633 "Sitemap: https://jobs.sap.com/en/jobs/sitemap.xml\n")
634 fake = _Site(texts={
635 "https://jobs.sap.com/robots.txt": robots_txt,
636 "https://jobs.sap.com/jobs.xml.gz": UnicodeDecodeError("utf-8", b"\x1f\x8b", 0, 1, "invalid start byte"),
637 "https://jobs.sap.com/en/jobs/sitemap.xml": FX["sap_sitemap"],
638 })
639 items, artifact = _run("SAP", "https://www.sap.com/", fake)
640 assert artifact["provider"] == "sitemap" and len(items) == 6
641 # A job sitemap that could not be read leaves the count a floor.
642 assert artifact["open_roles_floor"] is True
643
644
645 def test_a_role_listed_in_each_language_s_sitemap_counts_once():
646 index = ('<sitemapindex><sitemap><loc>https://jobs.sap.com/en/jobs/sitemap.xml</loc></sitemap>'
647 '<sitemap><loc>https://jobs.sap.com/de/jobs/sitemap.xml</loc></sitemap></sitemapindex>')
648 german = FX["sap_sitemap"].replace("/en/", "/de/")
649 fake = _Site(texts={
650 "https://jobs.sap.com/robots.txt": FX["sap_robots"],
651 "https://jobs.sap.com/sitemap.xml": index,
652 "https://jobs.sap.com/en/jobs/sitemap.xml": FX["sap_sitemap"],
653 "https://jobs.sap.com/de/jobs/sitemap.xml": german,
654 })
655 _items, artifact = _run("SAP", "https://www.sap.com/", fake)
656 assert artifact["open_roles"] == 6 and artifact["open_roles_floor"] is False
657 assert "https://jobs.sap.com/de/jobs/sitemap.xml" not in fake.asked
658
659
660 def test_walled_role_pages_stop_after_the_first_wave():
661 urlset = "<urlset>" + "".join(
662 f"<url><loc>https://jobs.uber.com/en/jobs/{149500 + n}/</loc></url>" for n in range(40)
663 ) + "</urlset>"
664 fake = _Site(texts={
665 "https://jobs.uber.com/robots.txt": "User-Agent: *\nSitemap: https://jobs.uber.com/sitemap.xml\n",
666 "https://jobs.uber.com/sitemap.xml": urlset,
667 })
668 _items, artifact = _run("Uber", "https://www.uber.com/", fake)
669 role_pages = [url for url in fake.asked if "/en/jobs/1495" in url]
670 assert len(role_pages) == sitemap.TITLE_FIRST_WAVE
671 assert artifact["open_roles"] == 40 and artifact["board_titles_missing"]
672
673
674 def test_a_titled_sitemap_board_with_the_digest_off_does_not_claim_no_titles():
675 artifact = {"open_roles": 6, "titles_only": True, "owned": True}
676 footer = render._jobs_board_footer_line(_report(jobs=artifact))
677 assert footer == "💼 Jobs: 6 open roles │ from its job sitemap"
678
679
680 def test_the_robots_opt_in_is_read_from_the_env_file(tmp_path, monkeypatch):
681 import os
682
683 from lib import env
684 # setenv then delenv: the variable is unset now and restored after.
685 monkeypatch.setenv(robots.RESPECT_ROBOTS_VAR, "")
686 monkeypatch.delenv(robots.RESPECT_ROBOTS_VAR)
687 config_file = tmp_path / ".env"
688 config_file.write_text(f"{robots.RESPECT_ROBOTS_VAR}=1\n", encoding="utf-8")
689 monkeypatch.setattr(env, "CONFIG_FILE", config_file, raising=False)
690 try:
691 env.get_config()
692 assert robots.respect_robots()
693 finally:
694 os.environ.pop(robots.RESPECT_ROBOTS_VAR, None)
695
696
697 # --- review fixes -------------------------------------------------------------
698
699
700 def test_a_sitemap_cannot_point_the_lane_at_a_private_address():
701 urlset = (
702 "<urlset>"
703 "<url><loc>http://127.0.0.1:8080/jobs/12345</loc></url>"
704 "<url><loc>http://10.0.0.5/jobs/12346</loc></url>"
705 "<url><loc>http://localhost/jobs/12347</loc></url>"
706 "<url><loc>https://evil.example/jobs/12348</loc></url>"
707 "<url><loc>file:///etc/jobs/12349</loc></url>"
708 "<url><loc>https://jobs.uber.com/en/jobs/149574/</loc></url>"
709 "</urlset>"
710 )
711 fake = _Site(texts={
712 "https://jobs.uber.com/robots.txt": "User-Agent: *\nSitemap: https://jobs.uber.com/sitemap.xml\n",
713 "https://jobs.uber.com/sitemap.xml": urlset,
714 })
715 _items, artifact = _run("Uber", "https://www.uber.com/", fake)
716 assert not any(host in url for url in fake.asked for host in ("127.0.0.1", "10.0.0.5", "localhost", "evil.example", "file:"))
717 assert artifact["open_roles"] == 1
718
719
720 def test_a_role_page_redirected_off_the_site_gives_no_title():
721 urlset = '<urlset><url><loc>https://jobs.uber.com/en/jobs/149574/</loc></url></urlset>'
722 fake = _Site(texts={
723 "https://jobs.uber.com/robots.txt": "User-Agent: *\nSitemap: https://jobs.uber.com/sitemap.xml\n",
724 "https://jobs.uber.com/sitemap.xml": urlset,
725 "https://jobs.uber.com/en/jobs/149574/": "<title>Internal Admin Console</title>",
726 })
727 fake.redirects["https://jobs.uber.com/en/jobs/149574/"] = "http://192.168.1.1/admin"
728 items, artifact = _run("Uber", "https://www.uber.com/", fake)
729 assert items == [] and artifact["board_titles_missing"]
730
731
732 @pytest.mark.parametrize("title", [
733 "Just a moment...", "Access Denied", "Attention Required! | Cloudflare", "403 Forbidden", "Page Not Found",
734 ])
735 def test_a_block_page_answered_with_200_gives_no_title(title):
736 urlset = "<urlset>" + "".join(
737 f"<url><loc>https://jobs.uber.com/en/jobs/{149500 + n}/</loc></url>" for n in range(20)
738 ) + "</urlset>"
739 fake = _Site(texts={
740 "https://jobs.uber.com/robots.txt": "User-Agent: *\nSitemap: https://jobs.uber.com/sitemap.xml\n",
741 "https://jobs.uber.com/sitemap.xml": urlset,
742 "https://jobs.uber.com/en/jobs/*": f"<title>{title}</title>",
743 })
744 items, artifact = _run("Uber", "https://www.uber.com/", fake)
745 assert items == [] and artifact["board_titles_missing"]
746 # The first wave found only block pages, so the rest were not asked.
747 assert len([url for url in fake.asked if "/en/jobs/1495" in url]) == sitemap.TITLE_FIRST_WAVE
748 assert sitemap.title_from_page("<title>Senior Error Analysis Engineer</title>") == "Senior Error Analysis Engineer"
749
750
751 def test_an_unread_numbered_sitemap_on_a_jobs_host_leaves_the_count_a_floor():
752 index = ('<sitemapindex><sitemap><loc>https://jobs.sap.com/sitemap-1.xml</loc></sitemap>'
753 '<sitemap><loc>https://jobs.sap.com/sitemap-2.xml</loc></sitemap></sitemapindex>')
754 fake = _Site(texts={
755 "https://jobs.sap.com/robots.txt": FX["sap_robots"],
756 "https://jobs.sap.com/sitemap.xml": index,
757 "https://jobs.sap.com/sitemap-1.xml": FX["sap_sitemap"],
758 })
759 _items, artifact = _run("SAP", "https://www.sap.com/", fake)
760 assert artifact["open_roles"] == 6 and artifact["open_roles_floor"] is True
761
762
763 def test_a_capped_page_leaves_a_gap_so_an_older_row_does_not_cover_the_window():
764 # Asked for 500 a page, the server caps at 100: rows 100-499 are skipped.
765 # The older row on a later page must not declare the window read whole.
766 def page(offset):
767 def call(_deadline):
768 rows = [
769 {"id": f"r{n}", "title": f"Role {n}", "date": "2026-11-10" if n < 1000 else "2026-09-01"}
770 for n in range(offset, min(offset + 100, 2000))
771 ]
772 return {"rows": rows, "total": 2000}
773 return call
774
775 items, info = jobs._read_newest_first(
776 page, lambda payload: (payload["rows"], payload["total"]), page_size=500,
777 row_ceiling=7000, window_start="2026-10-15", deadline=jobs.time.monotonic() + 30,
778 newest_first=True,
779 )
780 assert any(row["date"] < "2026-10-15" for row in items)
781 assert info["board_window_covered"] is False
782 assert jobs._board_counts(items, info, WINDOW)["new_in_window"] is None
783
784
785 def test_the_eightfold_fallback_generation_is_checked_against_robots(monkeypatch):
786 monkeypatch.setenv(robots.RESPECT_ROBOTS_VAR, "1")
787 asked = []
788
789 def generation(entry, *, deadline):
790 asked.append(entry["api"])
791 return [], {}
792
793 monkeypatch.setattr(jobs, "_read_eightfold_generation", generation)
794 with patch.object(jobs.http, "get_text", side_effect=_Site(texts={
795 "https://careers.example.com/robots.txt": "User-agent: *\nDisallow: /api/apply/\n",
796 }).text):
797 jobs.read_eightfold_board(
798 {"board": "careers.example.com", "domain": "example.com"},
799 deadline=jobs._clock()() + 30, date_range=WINDOW,
800 )
801 assert asked == ["pcsx"]
802 assert jobs._listing_url(jobs.COMPANY_PROVIDER_EIGHTFOLD, {"board": "b.example", "api": "v2"}) == \
803 "https://b.example/api/apply/v2/jobs"
804
805
806 def test_a_redirect_to_a_private_address_is_refused_before_it_is_followed():
807 import io
808 import urllib.error
809 import urllib.request
810 from email.message import Message
811
812 handler = http._StripAuthOnCrossOriginRedirect()
813 req = urllib.request.Request("https://jobs.uber.com/en/jobs/149574/")
814 setattr(req, http._REDIRECT_GUARD_ATTR, sitemap._guard(req.full_url))
815 with pytest.raises(urllib.error.HTTPError):
816 handler.redirect_request(req, io.BytesIO(), 302, "Found", Message(), "http://192.168.1.1/admin")
817 followed = handler.redirect_request(
818 req, io.BytesIO(), 302, "Found", Message(), "https://jobs.uber.com/en/jobs/149574/data-engineer",
819 )
820 # A redirect on the site is followed and keeps the check for the next hop.
821 assert getattr(followed, http._REDIRECT_GUARD_ATTR) is getattr(req, http._REDIRECT_GUARD_ATTR)
822
823
824 def test_role_pages_from_a_sitemap_are_fetched_with_the_redirect_check():
825 urlset = '<urlset><url><loc>https://jobs.uber.com/en/jobs/149574/</loc></url></urlset>'
826 guards = []
827 fake = _Site(texts={
828 "https://jobs.uber.com/robots.txt": "User-Agent: *\nSitemap: https://jobs.uber.com/sitemap.xml\n",
829 "https://jobs.uber.com/sitemap.xml": urlset,
830 })
831 original = fake.text
832
833 def text(url, *args, **kwargs):
834 if "/en/jobs/" in url:
835 guards.append(kwargs.get("redirect_guard"))
836 return original(url, *args, **kwargs)
837
838 fake.text = text
839 _run("Uber", "https://www.uber.com/", fake)
840 assert guards and all(guard is not None for guard in guards)
841 assert not guards[0]("http://127.0.0.1/") and guards[0]("https://jobs.uber.com/en/jobs/1/")
842
843
844 def test_a_same_site_name_that_resolves_to_a_private_address_is_not_fetched(monkeypatch):
845 urlset = (
846 "<urlset><url><loc>https://internal.jobs.uber.com/en/jobs/149573/</loc></url>"
847 "<url><loc>https://jobs.uber.com/en/jobs/149574/</loc></url></urlset>"
848 )
849 fake = _Site(texts={
850 "https://jobs.uber.com/robots.txt": "User-Agent: *\nSitemap: https://jobs.uber.com/sitemap.xml\n",
851 "https://jobs.uber.com/sitemap.xml": urlset,
852 })
853 _items, artifact = _run("Uber", "https://www.uber.com/", fake)
854 assert not any("internal." in url for url in fake.asked)
855 assert artifact["open_roles"] == 1
856
857
858 def test_name_resolution_rejects_any_private_answer(monkeypatch):
859 import socket
860
861 answers = {
862 "public.example": ["93.184.216.34"],
863 "mixed.example": ["93.184.216.34", "10.1.2.3"],
864 "loopback.example": ["127.0.0.1"],
865 "v6local.example": ["fe80::1%en0"],
866 }
867
868 def getaddrinfo(name, *_args, **_kwargs):
869 if name not in answers:
870 raise socket.gaierror("no such name")
871 return [(socket.AF_INET, socket.SOCK_STREAM, 6, "", (address, 0)) for address in answers[name]]
872
873 monkeypatch.setattr(sitemap.socket, "getaddrinfo", getaddrinfo)
874 resolve = _REAL_RESOLVES_PUBLIC
875 resolve.cache_clear()
876 try:
877 assert resolve("public.example") is True
878 assert resolve("mixed.example") is False
879 assert resolve("loopback.example") is False
880 assert resolve("v6local.example") is False
881 assert resolve("missing.example") is False
882 finally:
883 resolve.cache_clear()
884
885
886 def test_a_robots_txt_sitemap_on_a_private_address_is_not_fetched():
887 robots_txt = (
888 "User-Agent: *\n"
889 "Sitemap: http://127.0.0.1:8080/jobs/sitemap.xml\n"
890 "Sitemap: https://internal.jobs.uber.com/sitemap.xml\n"
891 "Sitemap: https://jobs.uber.com/sitemap.xml\n"
892 )
893 fake = _Site(texts={
894 "https://jobs.uber.com/robots.txt": robots_txt,
895 "https://jobs.uber.com/sitemap.xml": '<urlset><url><loc>https://jobs.uber.com/en/jobs/149574/</loc></url></urlset>',
896 })
897 _items, artifact = _run("Uber", "https://www.uber.com/", fake)
898 assert not any("127.0.0.1" in url or "internal." in url for url in fake.asked)
899 assert artifact["open_roles"] == 1
900
901
902 # --- Kula -----------------------------------------------------------------------
903
904 KULA_ENTRY = {"name": "Nothing", "provider": "kula", "board": "careers.kula.ai", "slug": "nothing"}
905 KULA_ROLE_PAGE = "https://careers.kula.ai/nothing/*"
906
907
908 def test_a_kula_listing_parses_every_role_with_its_team_location_and_url():
909 items, total = kula.parse_listing(FX["kula_list"], KULA_ENTRY)
910 assert total == 19 and len(items) == 19
911 assert all(item["title"] and item["department"] and item["location"] and item["url"] for item in items)
912 growth = next(item for item in items if item["title"] == "Growth Lead, Subscription Products")
913 assert growth["id"] == "KL58931" and growth["provider"] == "kula"
914 assert growth["department"] == "Labs"
915 assert growth["location"] == "London, England, United Kingdom"
916 assert growth["locations"] == [
917 "London, England, United Kingdom", "San Francisco, California, United States",
918 ]
919 assert growth["url"] == "https://careers.kula.ai/nothing/58931-growth-lead-subscription-products"
920 assert growth["date"] == "2026-07-23" and growth["posted_date_true"]
921 assert growth["company_name"] == "Nothing Technology"
922 ai_native = sorted(item["title"] for item in items if item["department"] == "AI Native")
923 assert ai_native == [
924 "Applied AI Engineer", "Head of AI Partnerships & Strategy, North America",
925 "Software Engineer, On-Device AI",
926 ]
927
928
929 def test_a_kula_role_page_fills_the_role_text_and_posted_date_from_its_jobposting():
930 item = {"url": "https://careers.kula.ai/nothing/58931-growth-lead-subscription-products",
931 "description": "", "date": None, "posted_date_true": False}
932 with patch.object(kula.http, "get_text", return_value=FX["kula_job"]):
933 assert kula.fetch_details([item], deadline=jobs.time.monotonic() + 5) == (0, 0)
934 assert item["description"].startswith("About Nothing Nothing exists to make tech feel exciting again.")
935 assert item["date"] == "2026-07-23" and item["posted_date_true"]
936
937
938 def test_a_kula_page_whose_payload_holds_no_role_list_is_a_shape_error():
939 with pytest.raises(jobs.BoardShapeError):
940 kula.parse_listing("<html><body><h2>Open positions</h2></body></html>", KULA_ENTRY)
941
942
943 def _kula_role_page(url):
944 # Each role gets a sentence of its own, so it survives boilerplate removal.
945 ident = url.rsplit("/", 1)[1].split("-", 1)[0]
946 return FX["kula_job"].replace('"description": "', f'"description": "<p>Own role {ident}.</p>', 1)
947
948
949 def _kula_site(listing):
950 return _Site(texts={
951 "https://careers.kula.ai/nothing": listing,
952 KULA_ROLE_PAGE: _kula_role_page,
953 })
954
955
956 def test_nothing_s_board_is_read_from_kula_through_its_registered_careers_page():
957 fake = _kula_site(FX["kula_list"])
958 items, artifact = _run("Nothing", "https://nothing.tech/", fake)
959 assert artifact["tier"] == "ats" and artifact["provider"] == "kula"
960 assert artifact["owned"] and artifact["found_via"] == "site"
961 assert artifact["open_roles"] == 19 and len(items) == 19
962 # Roles posted 2026-10-27 through 2026-11-12, inside the window.
963 assert artifact["new_in_window"] == 7
964 roles = artifact["digest"]["roles"]
965 assert roles and all("Own role " in role["text"] for role in roles)
966 assert sum(1 for url in fake.asked if url.startswith("https://careers.kula.ai/nothing/")) == len(roles)
967 rendered = render.render_compact(_report(jobs=artifact))
968 assert "\n## Jobs Digest\n" in rendered and "💼 Jobs: 19 open roles" in rendered
969
970
971 def test_a_careers_page_linking_a_kula_board_is_read_through_kula():
972 fake = _kula_site(FX["kula_list"].replace("careers.kula.ai/nothing", "careers.kula.ai/initech"))
973 fake.texts = {
974 "https://initech.com/careers": '<a href="https://careers.kula.ai/initech">Open roles</a>',
975 "https://careers.kula.ai/initech": fake.texts["https://careers.kula.ai/nothing"],
976 "https://careers.kula.ai/initech/*": _kula_role_page,
977 }
978 assert jobs.detect_ats(fake.texts["https://initech.com/careers"]) == ("kula", "initech")
979 items, artifact = _run("Initech", "https://initech.com/", fake)
980 assert artifact["provider"] == "kula" and artifact["owned"]
981 assert artifact["open_roles"] == 19 and "digest" in artifact
982 assert "https://careers.kula.ai/initech" in fake.asked
983
984
985 def test_a_kula_board_whose_payload_changed_is_logged_and_the_run_goes_on(capsys):
986 changed = FX["kula_list"].replace('\\"jobs\\":', '\\"openings\\":')
987 assert changed != FX["kula_list"]
988 items, artifact = _run("Nothing", "https://nothing.tech/", _kula_site(changed))
989 assert items == [] and artifact["tier"] == "web" and "digest" not in artifact
990 assert "kula board careers.kula.ai could not be read (BoardShapeError)" in capsys.readouterr().err
991
992
993 def test_a_kula_board_that_times_out_raises_the_timeout_not_a_shape_error():
994 timeout = http.HTTPError("timed out", outcome_state=health.TIMEOUT)
995
996 def get_text(*_args, **_kwargs):
997 http._record_failure(timeout)
998 return None
999
1000 with patch.object(kula.http, "get_text", side_effect=get_text), http.capture_failures():
1001 with pytest.raises(http.HTTPError) as raised:
1002 kula.read_board(KULA_ENTRY, deadline=jobs.time.monotonic() + 5, date_range=WINDOW)
1003 assert raised.value.outcome_state == health.TIMEOUT
1004
1004 lines PYTHON