| 1 | """Jobs for a person who leads a company, and for a topic with no board. |
| 2 | |
| 3 | Evidence, two live runs on 2026-11-10: "Jensen Huang" with |
| 4 | ``--ticker NVDA:Nvidia`` printed "Jobs: 0 results", and "Kanye West" printed |
| 5 | "Jobs unreachable: URL Error: [Errno 8] nodename nor servname provided". |
| 6 | """ |
| 7 | |
| 8 | import socket |
| 9 | import urllib.error |
| 10 | from unittest.mock import MagicMock, patch |
| 11 | |
| 12 | import last30days as cli |
| 13 | from lib import http, jobs, pipeline, schema, yahoo_finance |
| 14 | |
| 15 | WINDOW = ("2026-10-12", "2026-11-11") |
| 16 | |
| 17 | # nvidia.com/careers on 2026-11-10: a landing page that names no hiring |
| 18 | # system and links to the job search on a host of its own. |
| 19 | LANDING = """ |
| 20 | <a href="https://www.nvidia.com/en-eu/about-nvidia/careers/">Europe</a> |
| 21 | <a href="https://www.nvidia.com/en-us/about-nvidia/careers/life-at-nvidia/">Life at NVIDIA</a> |
| 22 | <a href="https://jobs.nvidia.com/careers">Open Positions</a> |
| 23 | <h2>Join our team</h2> |
| 24 | """ |
| 25 | # jobs.nvidia.com/careers names the Workday board in its sign-in link. |
| 26 | JOB_SEARCH = '<a href="https://nvidia.wd5.myworkdayjobs.com/NVIDIAExternalCareerSite/login">Sign in</a>' |
| 27 | |
| 28 | |
| 29 | def _workday_rows(count=6): |
| 30 | return [ |
| 31 | { |
| 32 | "id": f"JR{index}", "title": f"Engineer {index}", "provider": "workday", |
| 33 | "url": f"https://nvidia.wd5.myworkdayjobs.com/NVIDIAExternalCareerSite/job/JR{index}", |
| 34 | "description": "", "date": None, "department": f"Team {index}", "location": "Santa Clara", |
| 35 | } |
| 36 | for index in range(count) |
| 37 | ] |
| 38 | |
| 39 | |
| 40 | def _pages(pages): |
| 41 | fetched = [] |
| 42 | |
| 43 | def get_text(url, **_kwargs): |
| 44 | fetched.append(url) |
| 45 | return pages.get(url) |
| 46 | |
| 47 | return fetched, get_text |
| 48 | |
| 49 | |
| 50 | def _board(token, *, deadline): |
| 51 | assert token == "nvidia.wd5/NVIDIAExternalCareerSite" |
| 52 | return _workday_rows(), {"board_total": 6, "board_capped": False, "board_cut_short": False} |
| 53 | |
| 54 | |
| 55 | # --- Defect 3: the board one link past the official careers page --- |
| 56 | |
| 57 | |
| 58 | def test_board_named_on_the_jobs_page_the_official_careers_page_links_to_is_found_and_owned(): |
| 59 | fetched, get_text = _pages({ |
| 60 | "https://www.nvidia.com/careers": LANDING, |
| 61 | "https://jobs.nvidia.com/careers": JOB_SEARCH, |
| 62 | }) |
| 63 | with patch("lib.jobs.http.get_text", side_effect=get_text), \ |
| 64 | patch.object(jobs, "search_workday_board", side_effect=_board), \ |
| 65 | patch.object(jobs, "fetch_workday_details", return_value=(0, 0)), \ |
| 66 | patch("lib.jobs.http.get", side_effect=AssertionError("no slug is guessed")): |
| 67 | items, artifact = jobs.search_jobs( |
| 68 | "Nvidia", WINDOW, {}, web_backend="none", site="https://www.nvidia.com/", |
| 69 | ) |
| 70 | # The board's tenant robots.txt is asked for the tenant's other career sites. |
| 71 | assert fetched == [ |
| 72 | "https://www.nvidia.com/careers", "https://jobs.nvidia.com/careers", |
| 73 | "https://nvidia.wd5.myworkdayjobs.com/robots.txt", |
| 74 | ] |
| 75 | assert len(items) == 6 |
| 76 | assert artifact["tier"] == "ats" |
| 77 | assert artifact["provider"] == "workday" |
| 78 | assert artifact["found_via"] == "site" |
| 79 | assert artifact["owned"] is True |
| 80 | assert artifact["digest"]["roles"] |
| 81 | |
| 82 | |
| 83 | def test_jobs_page_on_another_companys_domain_is_not_followed(): |
| 84 | landing = '<a href="https://jobs.other.example/careers">Open Positions</a><h2>Join our team</h2>' |
| 85 | fetched, get_text = _pages({"https://www.nvidia.com/careers": landing}) |
| 86 | with patch("lib.jobs.http.get_text", side_effect=get_text), \ |
| 87 | patch("lib.jobs.http.get", side_effect=http.HTTPError("missing", status_code=404)): |
| 88 | items, artifact = jobs.search_jobs( |
| 89 | "Nvidia", WINDOW, {}, web_backend="none", site="https://www.nvidia.com/", |
| 90 | ) |
| 91 | assert "https://jobs.other.example/careers" not in fetched |
| 92 | assert items == [] |
| 93 | assert artifact["tier"] == "web" |
| 94 | |
| 95 | |
| 96 | def test_board_reached_from_a_guessed_domain_stays_unowned_and_has_no_digest(): |
| 97 | # No official site is known: nvidia.com is a guess from the name, and a |
| 98 | # Workday board states no company name, so nothing says whose board it is. |
| 99 | fetched, get_text = _pages({ |
| 100 | "https://nvidia.com/careers": LANDING.replace("www.nvidia.com", "nvidia.com"), |
| 101 | "https://jobs.nvidia.com/careers": JOB_SEARCH, |
| 102 | }) |
| 103 | with patch("lib.jobs.http.get_text", side_effect=get_text), \ |
| 104 | patch.object(jobs, "search_workday_board", side_effect=_board): |
| 105 | items, artifact = jobs.search_jobs("Nvidia", WINDOW, {}, web_backend="none") |
| 106 | assert len(items) == 6 |
| 107 | assert artifact["found_via"] == "guess" |
| 108 | assert artifact["owned"] is False |
| 109 | assert "digest" not in artifact |
| 110 | |
| 111 | |
| 112 | # --- Defect 3: the host's company when Wikidata names none --- |
| 113 | |
| 114 | |
| 115 | def _run_jobs_lane(company, search): |
| 116 | subquery = schema.SubQuery( |
| 117 | label="primary", search_query="Jensen Huang", ranking_query="Jensen Huang", sources=["jobs"], |
| 118 | ) |
| 119 | with patch.object(jobs, "search_jobs", side_effect=search) as mock: |
| 120 | result = pipeline._retrieve_stream_impl( |
| 121 | topic="Jensen Huang", subquery=subquery, source="jobs", config={"_company": company}, |
| 122 | depth="default", date_range=WINDOW, runtime=None, mock=False, |
| 123 | web_backend="auto", raw_topic="Jensen Huang", |
| 124 | ) |
| 125 | return result, [call.args[0] for call in mock.call_args_list], mock |
| 126 | |
| 127 | |
| 128 | def test_host_ticker_company_is_searched_when_wikidata_named_none_and_the_topic_has_no_board(): |
| 129 | board = {"tier": "ats", "provider": "workday", "open_roles": 6} |
| 130 | |
| 131 | def search(name, *_args, **_kwargs): |
| 132 | return (_workday_rows(), board) if name == "Nvidia" else ([], {"tier": "web"}) |
| 133 | |
| 134 | (items, artifact), names, mock = _run_jobs_lane({"host_company": "Nvidia"}, search) |
| 135 | assert names == ["Jensen Huang", "Nvidia"] |
| 136 | assert len(items) == 6 and artifact is board |
| 137 | # No official site comes with the host's name, and no web search is spent. |
| 138 | assert mock.call_args.kwargs.get("site", "") == "" |
| 139 | assert mock.call_args.kwargs["web_backend"] == "none" |
| 140 | |
| 141 | |
| 142 | def test_topic_with_its_own_board_never_reaches_the_host_ticker_company(): |
| 143 | # "Waymo" with --ticker GOOGL:Alphabet: Waymo's board, not its parent's. |
| 144 | own = {"tier": "ats", "provider": "greenhouse", "open_roles": 3} |
| 145 | (_items, artifact), names, _mock = _run_jobs_lane( |
| 146 | {"host_company": "Alphabet"}, lambda name, *_a, **_k: ([{"id": "1"}], own), |
| 147 | ) |
| 148 | assert names == ["Jensen Huang"] |
| 149 | assert artifact is own |
| 150 | |
| 151 | |
| 152 | def test_host_ticker_company_with_no_board_leaves_the_topics_result(): |
| 153 | topic_result = ([], {"tier": "web", "resultCount": 0}) |
| 154 | result, names, _mock = _run_jobs_lane( |
| 155 | {"host_company": "Nvidia"}, |
| 156 | lambda name, *_a, **_k: topic_result if name == "Jensen Huang" else ([], {"tier": "web"}), |
| 157 | ) |
| 158 | assert names == ["Jensen Huang", "Nvidia"] |
| 159 | assert result == topic_result |
| 160 | |
| 161 | |
| 162 | def test_wikidata_company_is_searched_alone(): |
| 163 | _result, names, _mock = _run_jobs_lane( |
| 164 | {"company": "Nvidia", "company_site": "https://www.nvidia.com/", "host_company": "Other"}, |
| 165 | lambda name, *_a, **_k: ([], {"tier": "web"}), |
| 166 | ) |
| 167 | assert names == ["Nvidia"] |
| 168 | |
| 169 | |
| 170 | def test_jobs_company_takes_the_host_ticker_names_only_when_wikidata_named_none(): |
| 171 | one = yahoo_finance.parse_host_tickers("NVDA:Nvidia") |
| 172 | assert cli._company_for_jobs({}, one, "Jensen Huang") == {"host_companies": ["Nvidia"]} |
| 173 | resolved = {"company": "Nvidia", "company_site": "https://www.nvidia.com/"} |
| 174 | assert cli._company_for_jobs(resolved, one, "Jensen Huang") == resolved |
| 175 | # The topic is the company: its own name is already what is searched. |
| 176 | assert cli._company_for_jobs({}, one, "Nvidia") == {} |
| 177 | # An unusable pair names no company. |
| 178 | assert cli._company_for_jobs({}, yahoo_finance.parse_host_tickers("NVDA"), "Jensen Huang") == {} |
| 179 | assert cli._company_for_jobs({}, None, "Jensen Huang") == {} |
| 180 | |
| 181 | |
| 182 | # --- Defect 3: the digest of the led company's board survives ranking --- |
| 183 | |
| 184 | |
| 185 | def _job_candidate(index): |
| 186 | item = schema.SourceItem( |
| 187 | item_id=f"JR{index}", source="jobs", title=f"Engineer {index}", body="", |
| 188 | url=f"https://nvidia.wd5.myworkdayjobs.com/NVIDIAExternalCareerSite/job/JR{index}", |
| 189 | ) |
| 190 | return schema.Candidate( |
| 191 | candidate_id=f"c{index}", item_id=item.item_id, source="jobs", title=item.title, |
| 192 | url=item.url, snippet="", subquery_labels=["primary"], native_ranks={}, |
| 193 | local_relevance=0.1, freshness=50, engagement=None, source_quality=0.5, |
| 194 | rrf_score=0.1, sources=["jobs"], source_items=[item], |
| 195 | ) |
| 196 | |
| 197 | |
| 198 | def test_postings_dropped_for_not_naming_a_person_are_not_rejected_from_their_companys_digest(): |
| 199 | # The live run after the board was found: ranking dropped all 40 pooled |
| 200 | # Nvidia postings for not naming "Jensen Huang", which emptied the digest. |
| 201 | candidates = [_job_candidate(index) for index in range(3)] |
| 202 | board = {"company": "Nvidia", "owned": True, "tier": "ats"} |
| 203 | assert pipeline._rejected_job_keys(candidates, [], board, "Jensen Huang") == [] |
| 204 | |
| 205 | |
| 206 | def test_postings_ranking_dropped_on_the_topic_companys_own_board_stay_rejected(): |
| 207 | candidates = [_job_candidate(index) for index in range(3)] |
| 208 | board = {"company": "Nvidia", "owned": True, "tier": "ats"} |
| 209 | rejected = pipeline._rejected_job_keys(candidates, candidates[:1], board, "Nvidia") |
| 210 | assert len(rejected) == 2 |
| 211 | # A board that is not known to be the company's keeps its rejections too. |
| 212 | unowned = {"company": "Nvidia", "owned": False, "tier": "ats"} |
| 213 | assert len(pipeline._rejected_job_keys(candidates, [], unowned, "Jensen Huang")) == 3 |
| 214 | assert len(pipeline._rejected_job_keys(candidates, [], None, "Jensen Huang")) == 3 |
| 215 | |
| 216 | |
| 217 | # --- Defect 4: a careers host that does not exist is "no board", not an outage --- |
| 218 | |
| 219 | |
| 220 | def _dns_failure(*_args, **_kwargs): |
| 221 | raise urllib.error.URLError( |
| 222 | socket.gaierror(8, "nodename nor servname provided, or not known") |
| 223 | ) |
| 224 | |
| 225 | |
| 226 | def _refused(*_args, **_kwargs): |
| 227 | raise urllib.error.URLError(ConnectionRefusedError(61, "Connection refused")) |
| 228 | |
| 229 | |
| 230 | def _open_by_host(careers_open): |
| 231 | """Guessed careers hosts fail with ``careers_open``; every ATS API says 404.""" |
| 232 | def opener(req, timeout=None, **_kwargs): |
| 233 | host = req.full_url.split("/")[2] |
| 234 | if host in {"kanyewest.com", "kanyewest.ai", "kanyewest.io"}: |
| 235 | return careers_open() |
| 236 | raise urllib.error.HTTPError(req.full_url, 404, "Not Found", {}, None) |
| 237 | return opener |
| 238 | |
| 239 | |
| 240 | def _search_capturing(opener, company="Kanye West"): |
| 241 | with patch.object(http, "_open_request", side_effect=opener), \ |
| 242 | patch.object(http.time, "sleep"), \ |
| 243 | http.capture_failures() as failures: |
| 244 | result = jobs.search_jobs(company, WINDOW, {}, web_backend="none") |
| 245 | return result, failures |
| 246 | |
| 247 | |
| 248 | def test_guessed_careers_host_that_does_not_resolve_is_no_board_found(): |
| 249 | (items, artifact), failures = _search_capturing(_open_by_host(_dns_failure)) |
| 250 | assert items == [] |
| 251 | assert artifact["tier"] == "web" |
| 252 | assert failures == [] |
| 253 | |
| 254 | |
| 255 | def test_guessed_careers_host_that_refuses_the_connection_is_no_board_found(): |
| 256 | (items, _artifact), failures = _search_capturing(_open_by_host(_refused)) |
| 257 | assert items == [] |
| 258 | assert failures == [] |
| 259 | |
| 260 | |
| 261 | def test_host_that_does_not_resolve_is_asked_for_one_page_only(): |
| 262 | asked = [] |
| 263 | |
| 264 | def opener(req, timeout=None, **_kwargs): |
| 265 | asked.append(req.full_url) |
| 266 | return _open_by_host(_dns_failure)(req, timeout) |
| 267 | |
| 268 | _search_capturing(opener) |
| 269 | assert not [url for url in asked if url.endswith("/jobs") and "kanyewest" in url] |
| 270 | |
| 271 | |
| 272 | def test_guessed_careers_host_that_times_out_is_no_board_found(): |
| 273 | # "Sundar Pichai" on 2026-11-10: sundarpichai.com and sundarpichai.ai never |
| 274 | # answered, and the run printed "Jobs timeout: URL Error: timed out". A |
| 275 | # domain guessed from a name that does not answer is no site of the |
| 276 | # topic's, not an outage of the lane. See tests/test_jobs_reliability.py. |
| 277 | def timed_out(): |
| 278 | raise urllib.error.URLError(TimeoutError("timed out")) |
| 279 | |
| 280 | (items, artifact), failures = _search_capturing(_open_by_host(timed_out)) |
| 281 | assert items == [] |
| 282 | assert failures == [] |
| 283 | assert "_source_outcome" not in artifact |
| 284 | |
| 285 | |
| 286 | def test_outage_of_a_known_hiring_system_is_still_an_error(): |
| 287 | def opener(req, timeout=None, **_kwargs): |
| 288 | host = req.full_url.split("/")[2] |
| 289 | if host == "boards-api.greenhouse.io": |
| 290 | return _dns_failure() |
| 291 | raise urllib.error.HTTPError(req.full_url, 404, "Not Found", {}, None) |
| 292 | |
| 293 | with patch.object(http, "_open_request", side_effect=opener), \ |
| 294 | patch.object(http.time, "sleep"), \ |
| 295 | http.capture_failures() as failures: |
| 296 | try: |
| 297 | jobs.search_jobs("Kanye West", WINDOW, {}, web_backend="none") |
| 298 | raised = None |
| 299 | except http.HTTPError as exc: |
| 300 | raised = exc |
| 301 | assert raised is not None and raised.outcome_state == http.health.UNREACHABLE |
| 302 | assert [f for f in failures if f.no_host] |
| 303 | |
| 304 | |
| 305 | def test_dns_failure_outside_a_guessed_host_is_recorded_as_before(): |
| 306 | with patch.object(http, "_open_request", side_effect=_dns_failure), \ |
| 307 | patch.object(http.time, "sleep"), \ |
| 308 | http.capture_failures() as failures: |
| 309 | assert http.get_text("https://api.example.com/x", retries=1) is None |
| 310 | assert len(failures) == 1 and failures[0].no_host |
| 311 | |
| 312 | |
| 313 | # --- A known official site that does not answer is an outage, not "no board" --- |
| 314 | |
| 315 | OFFICIAL = "https://www.acmecorp.com/" |
| 316 | |
| 317 | |
| 318 | def _search_official(opener): |
| 319 | with patch.object(http, "_open_request", side_effect=opener), \ |
| 320 | patch.object(http.time, "sleep"), \ |
| 321 | http.capture_failures() as failures: |
| 322 | result = jobs.search_jobs( |
| 323 | "Acme", WINDOW, {}, web_backend="none", site=OFFICIAL, |
| 324 | ) |
| 325 | return result, failures |
| 326 | |
| 327 | |
| 328 | def _official_host_fails(careers_open): |
| 329 | def opener(req, timeout=None, **_kwargs): |
| 330 | if req.full_url.split("/")[2] == "www.acmecorp.com": |
| 331 | return careers_open() |
| 332 | raise urllib.error.HTTPError(req.full_url, 404, "Not Found", {}, None) |
| 333 | return opener |
| 334 | |
| 335 | |
| 336 | def test_official_site_that_does_not_resolve_is_recorded_as_a_failure(): |
| 337 | (items, _artifact), failures = _search_official(_official_host_fails(_dns_failure)) |
| 338 | assert items == [] |
| 339 | assert failures and all( |
| 340 | f.no_host and f.outcome_state == http.health.UNREACHABLE for f in failures |
| 341 | ) |
| 342 | |
| 343 | |
| 344 | def test_official_site_that_refuses_the_connection_is_recorded_as_a_failure(): |
| 345 | _result, failures = _search_official(_official_host_fails(_refused)) |
| 346 | assert failures and all(f.no_host for f in failures) |
| 347 | |
| 348 | |
| 349 | def test_jobs_page_linked_from_the_official_site_that_does_not_resolve_is_recorded(): |
| 350 | landing = '<a href="https://jobs.acmecorp.com/careers">Open Positions</a><h2>Join our team</h2>' |
| 351 | |
| 352 | def opener(req, timeout=None, **_kwargs): |
| 353 | host = req.full_url.split("/")[2] |
| 354 | if host == "www.acmecorp.com": |
| 355 | response = MagicMock() |
| 356 | response.__enter__.return_value = response |
| 357 | response.__exit__.return_value = False |
| 358 | response.read.return_value = landing.encode("utf-8") |
| 359 | response.status = 200 |
| 360 | response.headers = {} |
| 361 | return response |
| 362 | if host == "jobs.acmecorp.com": |
| 363 | return _dns_failure() |
| 364 | raise urllib.error.HTTPError(req.full_url, 404, "Not Found", {}, None) |
| 365 | |
| 366 | _result, failures = _search_official(opener) |
| 367 | assert [f for f in failures if f.no_host] |
| 368 | |
| 369 | |
| 370 | # --- A known site that drops the connection on one host form --------------------- |
| 371 | |
| 372 | |
| 373 | def _dropped(*_args, **_kwargs): |
| 374 | from http.client import RemoteDisconnected |
| 375 | |
| 376 | raise RemoteDisconnected("Remote end closed connection without response") |
| 377 | |
| 378 | |
| 379 | def _html(text): |
| 380 | response = MagicMock() |
| 381 | response.__enter__.return_value = response |
| 382 | response.__exit__.return_value = False |
| 383 | response.read.return_value = text.encode("utf-8") |
| 384 | response.status = 200 |
| 385 | response.headers = {} |
| 386 | return response |
| 387 | |
| 388 | |
| 389 | def _by_host(asked, answers): |
| 390 | """Answer each request from ``answers`` keyed by host, else 404.""" |
| 391 | def opener(req, timeout=None, **_kwargs): |
| 392 | asked.append(req.full_url) |
| 393 | host = req.full_url.split("/")[2] |
| 394 | if host in answers: |
| 395 | return answers[host](req.full_url) |
| 396 | raise urllib.error.HTTPError(req.full_url, 404, "Not Found", {}, None) |
| 397 | return opener |
| 398 | |
| 399 | |
| 400 | def _unreachable(failures): |
| 401 | return [f for f in failures if f.outcome_state == http.health.UNREACHABLE] |
| 402 | |
| 403 | |
| 404 | def test_known_bare_site_that_drops_the_connection_is_read_on_its_www_form(): |
| 405 | asked = [] |
| 406 | landing = "<h2>Join our team</h2>" |
| 407 | opener = _by_host(asked, { |
| 408 | "acmecorp.com": _dropped, |
| 409 | "www.acmecorp.com": lambda url: _html(landing) if url.endswith("/careers") else _dropped(), |
| 410 | }) |
| 411 | with patch.object(http, "_open_request", side_effect=opener), \ |
| 412 | patch.object(http.time, "sleep"), \ |
| 413 | http.capture_failures() as failures: |
| 414 | jobs.search_jobs("Acme", WINDOW, {}, web_backend="none", site="https://acmecorp.com/") |
| 415 | assert asked[:2] == ["https://acmecorp.com/careers", "https://www.acmecorp.com/careers"] |
| 416 | assert _unreachable(failures) == [] |
| 417 | |
| 418 | |
| 419 | def test_known_site_whose_both_forms_drop_the_connection_is_one_outage(): |
| 420 | asked = [] |
| 421 | opener = _by_host(asked, {"acmecorp.com": _dropped, "www.acmecorp.com": _dropped}) |
| 422 | with patch.object(http, "_open_request", side_effect=opener), \ |
| 423 | patch.object(http.time, "sleep"), \ |
| 424 | http.capture_failures() as failures: |
| 425 | jobs.search_jobs("Acme", WINDOW, {}, web_backend="none", site="https://acmecorp.com/") |
| 426 | assert [url for url in asked if url.split("/")[2] in ("acmecorp.com", "www.acmecorp.com")] == [ |
| 427 | "https://acmecorp.com/careers", "https://www.acmecorp.com/careers", |
| 428 | ] |
| 429 | assert len(_unreachable(failures)) == 1 |
| 430 | |
| 431 | |
| 432 | def test_known_site_whose_other_form_answers_404_is_asked_its_jobs_page_there(): |
| 433 | asked = [] |
| 434 | |
| 435 | def www(url): |
| 436 | if url.endswith("/jobs"): |
| 437 | return _html("<h2>Join our team</h2>") |
| 438 | raise urllib.error.HTTPError(url, 404, "Not Found", {}, None) |
| 439 | |
| 440 | opener = _by_host(asked, {"acmecorp.com": _dropped, "www.acmecorp.com": www}) |
| 441 | with patch.object(http, "_open_request", side_effect=opener), \ |
| 442 | patch.object(http.time, "sleep"): |
| 443 | jobs.search_jobs("Acme", WINDOW, {}, web_backend="none", site="https://acmecorp.com/") |
| 444 | assert asked[:3] == [ |
| 445 | "https://acmecorp.com/careers", "https://www.acmecorp.com/careers", |
| 446 | "https://www.acmecorp.com/jobs", |
| 447 | ] |
| 448 | |
| 449 | |
| 450 | def test_a_guessed_domain_on_the_unreadable_list_gets_no_request(): |
| 451 | asked = [] |
| 452 | _search_capturing(_by_host(asked, {}), company="Tesla") |
| 453 | assert asked and not [url for url in asked if url.split("/")[2] in ("tesla.com", "www.tesla.com")] |
| 454 | |
| 455 | |
| 456 | def test_guessed_domain_that_drops_the_connection_is_not_retried_on_another_form(): |
| 457 | asked = [] |
| 458 | opener = _by_host(asked, {"kanyewest.com": _dropped}) |
| 459 | _search_capturing(opener) |
| 460 | assert not [url for url in asked if "www.kanyewest" in url] |
| 461 | |
| 462 | |
| 463 | def test_known_site_that_answers_404_is_not_retried_on_another_form(): |
| 464 | asked = [] |
| 465 | opener = _by_host(asked, {}) |
| 466 | with patch.object(http, "_open_request", side_effect=opener), \ |
| 467 | patch.object(http.time, "sleep"): |
| 468 | jobs.search_jobs("Acme", WINDOW, {}, web_backend="none", site="https://acmecorp.com/") |
| 469 | assert "https://acmecorp.com/careers" in asked |
| 470 | assert not [url for url in asked if "www.acmecorp.com" in url] |
| 471 |