Read BambooHR boards from their careers list and role pages
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0b76b16daa
commit
76187d5862
5 files changed
+323
No files matched your search
@@ -0,0 +1,135 @@
|
||||
"""BambooHR: `bamboohr:<subdomain>` for acme.bamboohr.com, the whole board in
|
||||
one JSON answer and each role's text, date and country on its own page.
|
||||
|
||||
Written from Configit's board on 2026-09-29 (two roles); jobhunt-hq did not
|
||||
read BambooHR. Unverified: whether a large board pages `/careers/list` (this
|
||||
one states `meta.totalCount` and no paging keys, so a list shorter than its
|
||||
count is refused rather than read as the whole board), and the words of
|
||||
`locationType`, taken to be BambooHR's own settings, "0" in the office, "1"
|
||||
remote and "2" hybrid; Configit's hybrid roles say "2" and `isRemote` is null.
|
||||
|
||||
A posting that invites an unsolicited application without a role (Configit's
|
||||
first) is listed like any other role.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import html
|
||||
import json
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
|
||||
from desk.sources import strip_html
|
||||
|
||||
from ._shared import Get, Row, label_slug_ok, only, parse_dt
|
||||
|
||||
NAME = "bamboohr"
|
||||
LABEL = "BambooHR"
|
||||
PATTERNS = (
|
||||
# Not the company's own app or documentation subdomains, which BambooHR
|
||||
# itself serves and which name no board.
|
||||
r"https?://(?!(?:app|resources|documentation|help)\.)([a-z0-9-]+)\.bamboohr\.com",
|
||||
)
|
||||
|
||||
#: `locationType` -> `store._remote`'s words. Anything else says nothing.
|
||||
_REMOTE = {"0": "onsite", "1": "remote", "2": "hybrid"}
|
||||
|
||||
#: Sent on the detail read: without it the same URL answers the page's HTML.
|
||||
_JSON = {"Accept": "application/json"}
|
||||
|
||||
|
||||
def host(slug: str) -> str:
|
||||
return f"{slug.lower()}.bamboohr.com"
|
||||
|
||||
|
||||
def slug_ok(slug: str) -> bool:
|
||||
return label_slug_ok(slug)
|
||||
|
||||
|
||||
def allowed(slug: str) -> Callable[[str], bool]:
|
||||
return only(host(slug))
|
||||
|
||||
|
||||
def careers_url(slug: str) -> str:
|
||||
return f"https://{host(slug)}/careers"
|
||||
|
||||
|
||||
def robots_page(slug: str) -> str:
|
||||
return careers_url(slug)
|
||||
|
||||
|
||||
def feed_url(slug: str) -> str:
|
||||
return f"https://{host(slug)}/careers/list"
|
||||
|
||||
|
||||
def _remote(j: dict[str, Any]) -> str | None:
|
||||
if j.get("isRemote") is True:
|
||||
return "remote"
|
||||
return _REMOTE.get(str(j.get("locationType") if j.get("locationType") is not None else ""))
|
||||
|
||||
|
||||
def _place(j: dict[str, Any]) -> str:
|
||||
"""City, state and country of a role, as far as either of its two
|
||||
location objects states them (`atsLocation` mirrors `location` and is
|
||||
filled by companies that use BambooHR's own applicant tracking)."""
|
||||
place, ats_place = j.get("location") or {}, j.get("atsLocation") or {}
|
||||
country = place.get("addressCountry") or ats_place.get("country")
|
||||
parts = (place.get("city") or ats_place.get("city"),
|
||||
place.get("state") or ats_place.get("state"), country)
|
||||
return ", ".join(str(p).strip() for p in parts if p and str(p).strip())
|
||||
|
||||
|
||||
def parse(body: bytes, slug: str) -> list[Row]:
|
||||
"""`/careers/list` -> `{"meta": {"totalCount": n}, "result": [...]}`. A
|
||||
role has `id`, `jobOpeningName`, `departmentLabel`, `location` (`city`,
|
||||
`state`), `atsLocation` (the same with a `country`, null so far),
|
||||
`isRemote` and `locationType`. The text, the date and the country are only
|
||||
on the role's own page (`detail`), which is why `description` and `posted`
|
||||
are empty here."""
|
||||
data = json.loads(body)
|
||||
listed = data.get("result") if isinstance(data, dict) else None
|
||||
if not isinstance(listed, list):
|
||||
raise ValueError("not a BambooHR listing: no result list")
|
||||
stated = (data.get("meta") or {}).get("totalCount")
|
||||
if isinstance(stated, int) and stated > len(listed):
|
||||
raise ValueError(f"BambooHR listing has {len(listed)} of {stated} roles")
|
||||
out = []
|
||||
for j in listed:
|
||||
title = (j.get("jobOpeningName") or "").strip()
|
||||
source_id = str(j.get("id") or "")
|
||||
if not title or not source_id:
|
||||
continue
|
||||
out.append({
|
||||
"source_id": source_id,
|
||||
"title": title,
|
||||
"location": _place(j),
|
||||
"url": f"https://{host(slug)}/careers/{source_id}",
|
||||
"posted": None,
|
||||
"department": str(j.get("departmentLabel") or "").strip(),
|
||||
"description": "",
|
||||
"remote": _remote(j),
|
||||
"salary_text": "", # the list states no pay; the detail's `compensation` was null
|
||||
})
|
||||
return out
|
||||
|
||||
|
||||
def detail(get: Get, slug: str, row: Row) -> dict[str, Any]:
|
||||
"""`/careers/<id>/detail` -> `{"result": {"jobOpening": {...}}}`, with the
|
||||
HTML `description`, `datePosted` (a date), `location` (`city`, `state`,
|
||||
`addressCountry`) and `locationType`. The location is the listing's with
|
||||
the country added, since the listing has none."""
|
||||
data = json.loads(get(f"https://{host(slug)}/careers/{row['source_id']}/detail",
|
||||
headers=_JSON))
|
||||
opening = ((data.get("result") or {}).get("jobOpening")
|
||||
if isinstance(data, dict) else None)
|
||||
if not isinstance(opening, dict):
|
||||
raise ValueError("not a BambooHR role: no result.jobOpening")
|
||||
out: dict[str, Any] = {
|
||||
"description": " ".join(html.unescape(strip_html(opening.get("description") or "")).split()),
|
||||
"posted": parse_dt(opening.get("datePosted")),
|
||||
}
|
||||
if place := _place(opening):
|
||||
out["location"] = place
|
||||
if remote := _remote(opening):
|
||||
out["remote"] = remote
|
||||
return out
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"meta":{},"result":{"jobOpening":{"jobOpeningShareUrl":"https:\/\/configit.bamboohr.com\/careers\/26","jobOpeningName":"Unsolicited application - All Configit locations","jobOpeningStatus":"Open","jobCategoryId":null,"departmentId":null,"departmentLabel":"","employmentStatusLabel":"Full-Time","employmentType":null,"location":{"city":"K\u00f8benhavn \u00d8","state":null,"postalCode":"2100","addressCountry":"Denmark"},"atsLocation":{"country":null,"countryId":null,"state":null,"city":null},"description":"<p>Hi,<\/p>\n<p><br><\/p>\n<p>If there is currently no vacant position that matches your skills, you are welcome to send us an unsolicited application.<\/p>\n<p><br><\/p>\n<p>We are curious to hear about you and why you'd like to join us.<\/p>\n<p><br><\/p>\n<p>Please also let us know in which of our locations you'd like to work:<\/p>\n<p><br><\/p>\n<ul>\n<li>Copenhagen (Denmark)<\/li>\n<li>Langenfeld (Germany, D\u00fcsseldorf\/Cologne area)<\/li>\n<li>UK (remote)<\/li>\n<li>US (Atlanta)<\/li>\n<\/ul>\n<p><br><\/p>\n<ul><\/ul>\n<p>Our Global HR Team and our managers are looking forward to reviewing your application.<\/p>","compensation":null,"datePosted":"2025-10-10","minimumExperience":null,"locationType":"2","seekPromoted":false,"aiProcessingDisclosureEnabled":false},"formFields":{"firstName":{"isRequired":true,"value":"","label":"First Name"},"lastName":{"isRequired":true,"value":"","label":"Last Name"},"email":{"isRequired":true,"value":"","label":"Email"},"phone":{"isRequired":true,"value":"","label":"Phone"},"streetAddress":{"isRequired":true,"value":"","label":"Address"},"city":{"isRequired":true,"value":"","label":"City"},"state":{"isRequired":true,"value":"","label":"State","options":[]},"zip":{"isRequired":true,"value":"","label":"ZIP"},"countryId":{"isRequired":true,"value":"57","label":"Country","options":[{"id":"1","text":"United States"},{"id":"2","text":"Canada"},{"id":"3","text":"Australia"},{"id":"4","text":"Afghanistan"},{"id":"5","text":"Albania"},{"id":"6","text":"Algeria"},{"id":"7","text":"American Samoa"},{"id":"8","text":"Andorra"},{"id":"9","text":"Anguilla"},{"id":"10","text":"Angola"},{"id":"11","text":"Antarctica"},{"id":"12","text":"Antigua and Barbuda"},{"id":"13","text":"Argentina"},{"id":"14","text":"Armenia"},{"id":"15","text":"Aruba"},{"id":"16","text":"Austria"},{"id":"17","text":"Azerbaijan"},{"id":"18","text":"Bahamas"},{"id":"19","text":"Bahrain"},{"id":"20","text":"Bangladesh"},{"id":"21","text":"Barbados"},{"id":"22","text":"Belgium"},{"id":"23","text":"Belize"},{"id":"24","text":"Benin"},{"id":"25","text":"Bermuda"},{"id":"26","text":"Bhutan"},{"id":"27","text":"Bolivia"},{"id":"28","text":"Bosnia and Herzegovina"},{"id":"29","text":"Botswana"},{"id":"30","text":"Bouvet Island"},{"id":"31","text":"Brazil"},{"id":"32","text":"British Indian Ocean Territory"},{"id":"33","text":"Brunei Darussalam"},{"id":"34","text":"Bulgaria"},{"id":"35","text":"Burkina Faso"},{"id":"36","text":"Burundi"},{"id":"37","text":"Cambodia"},{"id":"38","text":"Cameroon"},{"id":"39","text":"Cape Verde"},{"id":"40","text":"Cayman Islands"},{"id":"41","text":"Central African Republic"},{"id":"42","text":"Chad"},{"id":"43","text":"Chile"},{"id":"44","text":"China"},{"id":"45","text":"Christmas Island"},{"id":"46","text":"Cocos (Keeling Islands)"},{"id":"47","text":"Colombia"},{"id":"48","text":"Comoros"},{"id":"49","text":"Congo"},{"id":"50","text":"Cook Islands"},{"id":"51","text":"Costa Rica"},{"id":"52","text":"Cote D'Ivoire (Ivory Coast)"},{"id":"53","text":"Croatia (Hrvatska)"},{"id":"54","text":"Cuba"},{"id":"55","text":"Cyprus"},{"id":"56","text":"Czech Republic"},{"id":"57","text":"Denmark"},{"id":"58","text":"Djibouti"},{"id":"59","text":"Dominica"},{"id":"60","text":"Dominican Republic"},{"id":"61","text":"East Timor"},{"id":"62","text":"Egypt"},{"id":"63","text":"El Salvador"},{"id":"64","text":"Ecuador"},{"id":"65","text":"Equatorial Guinea"},{"id":"66","text":"Eritrea"},{"id":"67","text":"Estonia"},{"id":"68","text":"Ethiopia"},{"id":"69","text":"Falkland Islands (Malvinas)"},{"id":"70","text":"Faroe Islands"},{"id":"71","text":"Fiji"},{"id":"72","text":"Finland"},{"id":"73","text":"France"},{"id":"74","text":"France, Metropolitan"},{"id":"75","text":"French Guiana"},{"id":"76","text":"French Polynesia"},{"id":"77","text":"French Southern Territories"},{"id":"78","text":"French West Indies"},{"id":"79","text":"Gabon"},{"id":"80","text":"Gambia"},{"id":"81","text":"Georgia"},{"id":"82","text":"Germany"},{"id":"83","text":"Ghana"},{"id":"84","text":"Gibraltar"},{"id":"85","text":"Greece"},{"id":"86","text":"Greenland"},{"id":"87","text":"Grenada"},{"id":"88","text":"Guadeloupe"},{"id":"89","text":"Guam"},{"id":"90","text":"Guatemala"},{"id":"91","text":"Guinea"},{"id":"92","text":"Guinea-Bissau"},{"id":"93","text":"Guyana"},{"id":"94","text":"Haiti"},{"id":"95","text":"Heard and McDonald Islands"},{"id":"96","text":"Honduras"},{"id":"97","text":"Hong Kong"},{"id":"98","text":"Hungary"}Line truncated
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"meta":{},"result":{"jobOpening":{"jobOpeningShareUrl":"https:\/\/configit.bamboohr.com\/careers\/37","jobOpeningName":"Demand Generation Specialist - 12-Month Maternity Cover","jobOpeningStatus":"Open","jobCategoryId":null,"departmentId":"18571","departmentLabel":"Marketing","employmentStatusLabel":"Full-Time","employmentType":null,"location":{"city":"K\u00f8benhavn \u00d8","state":null,"postalCode":"2100","addressCountry":"Denmark"},"atsLocation":{"country":null,"countryId":null,"state":null,"city":null},"description":"<p><em><span><span>Our Global Marketing Team is looking for a driven, creative, and passionate individual to join us for a 12-month fixed-term maternity cover. You\u2019ll help drive pipeline growth through impactful inbound and outbound campaigns that build awareness, generate demand, and deliver high-quality leads. If you\u2019re a hands-on marketer who enjoys turning strategy into results, we\u2019d love to hear from you<\/span>!<\/span><\/em><\/p>\n<p><br><\/p>\n<p><span>Configit is an ambitious and growing SaaS company working in the domain of complex product and sales configuration. We help large international corporations optimize their processes and drive cross-functional innovation through our Configuration Lifecycle Management approach. \u00a0<\/span><br><\/p>\n<p><br><\/p>\n<p><span>Within our dedicated Marketing Team, you will focus on refining existing marketing channels and developing new integrated digital campaigns with effective messaging to generate a qualified pipeline, to accelerate deals, and to grow our revenue.<\/span><\/p>\n<p><span>\u00a0<\/span><\/p>\n<p><span style=\"font-weight: bold\"><span>Your Responsibilities<\/span><\/span><\/p>\n<ul>\n<li><span>Create new and optimize existing inbound and outbound demand and lead generation programs across email and web.<\/span><\/li>\n<li><span>Develop, plan, and execute campaigns for paid search, retargeting, paid social channels, and email marketing.<\/span><\/li>\n<li><span>Execute and optimize ABM and ABS campaigns.<\/span><\/li>\n<li><span>Experiment with generative AI and other emerging marketing technologies to identify opportunities to improve marketing effectiveness and efficiency.<\/span><\/li>\n<li><span>Identify most effective marketing messages, value propositions, material, channels, and calls to action for target accounts.<\/span><\/li>\n<li><span>Measure, analyze, and report on the impact of marketing campaigns.<\/span><\/li>\n<li><span>Manage projects like the creation of campaign landing pages, creatives, and other digital marketing assets.<\/span><\/li>\n<li><span>Use intelligence from our intent data sources like 6sense and Dreamdata.<\/span><\/li>\n<li><span>Closely collaborate with core Sales, Marketing, Product Marketing, and Product Management functions.<\/span><\/li>\n<\/ul>\n<p><span>\u00a0<\/span><\/p>\n<p><span style=\"font-weight: bold\"><span>Your Skills & Experience<\/span><\/span><\/p>\n<ul>\n<li><span>Bachelor\u2019s or Master\u2019s degree in Marketing, Business, or a related field.<\/span><\/li>\n<li><span>3+ years of experience in digital marketing.<\/span><\/li>\n<li><span>Proficiency with marketing automation platforms, preferably Pardot.<\/span><\/li>\n<li><span>Familiarity with digital advertising platforms such as Google Ads, Google Analytics, Bing, LinkedIn Campaign Manager.<\/span><\/li>\n<li><span>Comfortable using generative AI tools in day-to-day marketing work and curious about identifying new ways to apply AI to improve quality, speed, personalization, and performance.<\/span><\/li>\n<li><span>Ability to critically evaluate AI-generated output and combine AI capabilities with strong marketing judgment, brand understanding, and human creativity.<\/span><\/li>\n<li><span>Experience building or improving AI-assisted workflows, prompts, or marketing automations is an advantage.<\/span><\/li>\n<li><span>Proven project management skills with attention to detail and ability to multitask.<\/span><\/li>\n<li><span>Strong analytical skills with the ability to interpret data, identify trends, and make data-driven decisions.<\/span><\/li>\n<li><span>Excellent communicator who enjoys collaborating across functions and geographies.<\/span><\/li>\n<li><span>Full English proficiency.<\/span><\/li>\n<\/ul>\n<p><span>\u00a0<\/span><\/p>\n<p><span style=\"font-weight: bold\"><span>What you'll find with us<\/span><\/span><\/p>\n<ul>\n<li><span>We provide a unique opportunity to work in a dynamic, ambitious, international company.<\/span><\/li>\n<li><span>We live our values * Business Focus * One Team * Can-do Attitude * Knowledge * Move Fast *.<\/span><\/li>\n<li><span>You will be based in our Danish office\u00a0but also work with colleagues in the US and Germany.<\/span><\/li>\n<li><span>Our HQ in Copenhagen has been recently renovated \u2013 we have beautiful views of the water and a great link to public transportation.<\/span><\/li>\n<li><span>We offer a flexible working policy.<\/span>Line truncated
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"meta":{"totalCount":2},"result":[{"id":"26","jobOpeningName":"Unsolicited application - All Configit locations","departmentId":null,"departmentLabel":null,"employmentStatusLabel":"Full-Time","employmentType":null,"location":{"city":"K\u00f8benhavn \u00d8","state":null},"atsLocation":{"country":null,"state":null,"province":null,"city":null},"isRemote":null,"locationType":"2"},{"id":"37","jobOpeningName":"Demand Generation Specialist - 12-Month Maternity Cover","departmentId":"18571","departmentLabel":"Marketing","employmentStatusLabel":"Full-Time","employmentType":null,"location":{"city":"K\u00f8benhavn \u00d8","state":null},"atsLocation":{"country":null,"state":null,"province":null,"city":null},"isRemote":null,"locationType":"2"}]}
|
||||
@@ -0,0 +1,185 @@
|
||||
"""The BambooHR host module against Configit's saved listing and two saved
|
||||
role pages. No network."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.jobs import discover # noqa: E402
|
||||
from plugins import ats, atshosts # noqa: E402
|
||||
from plugins.atshosts import bamboohr # noqa: E402
|
||||
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
|
||||
|
||||
|
||||
def _read(name: str) -> bytes:
|
||||
return (FIXTURES / name).read_bytes()
|
||||
|
||||
|
||||
def _get_of(answers: dict[str, bytes | Exception], asked: list[tuple[str, Any]]) -> Any:
|
||||
def get(url: str, *, method: str = "GET", payload: Any = None,
|
||||
headers: dict[str, str] | None = None) -> bytes:
|
||||
asked.append((url, headers))
|
||||
answer = answers[url]
|
||||
if isinstance(answer, Exception):
|
||||
raise answer
|
||||
return answer
|
||||
return get
|
||||
|
||||
|
||||
def test_a_listing_becomes_rows() -> None:
|
||||
rows = bamboohr.parse(_read("bamboohr.json"), "configit")
|
||||
assert [r["source_id"] for r in rows] == ["26", "37"]
|
||||
# The standing invitation to apply without a role is a role like any other.
|
||||
assert rows[0]["title"] == "Unsolicited application - All Configit locations"
|
||||
second = rows[1]
|
||||
assert second["title"] == "Demand Generation Specialist - 12-Month Maternity Cover"
|
||||
assert second["url"] == "https://configit.bamboohr.com/careers/37"
|
||||
assert second["department"] == "Marketing" and rows[0]["department"] == ""
|
||||
assert second["location"] == "København Ø"
|
||||
assert second["remote"] == "hybrid"
|
||||
assert (second["posted"], second["description"], second["salary_text"]) == (None, "", "")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("flag", "kind", "remote"), [
|
||||
(True, "0", "remote"), (None, "0", "onsite"), (None, "1", "remote"), (None, "2", "hybrid"),
|
||||
(None, None, None), (False, "7", None)])
|
||||
def test_remote_is_the_flag_then_the_location_type(
|
||||
flag: bool | None, kind: str | None, remote: str | None) -> None:
|
||||
body = json.loads(_read("bamboohr.json"))
|
||||
body["result"][0] |= {"isRemote": flag, "locationType": kind}
|
||||
assert bamboohr.parse(json.dumps(body).encode(), "configit")[0]["remote"] == remote
|
||||
|
||||
|
||||
def test_the_location_reads_the_state_and_the_ats_location_too() -> None:
|
||||
body = json.loads(_read("bamboohr.json"))
|
||||
body["result"][0]["location"] = {"city": "Austin", "state": "Texas"}
|
||||
body["result"][1]["location"] = {"city": None, "state": None}
|
||||
body["result"][1]["atsLocation"] = {"city": "Lyon", "state": None, "country": "France"}
|
||||
rows = bamboohr.parse(json.dumps(body).encode(), "configit")
|
||||
assert [r["location"] for r in rows] == ["Austin, Texas", "Lyon, France"]
|
||||
|
||||
|
||||
def test_a_list_shorter_than_its_count_is_refused_not_read_as_the_board() -> None:
|
||||
body = json.loads(_read("bamboohr.json"))
|
||||
body["meta"]["totalCount"] = 3
|
||||
with pytest.raises(ValueError, match="2 of 3"):
|
||||
bamboohr.parse(json.dumps(body).encode(), "configit")
|
||||
|
||||
|
||||
def test_a_page_that_is_not_a_listing_raises_and_an_empty_board_is_no_rows() -> None:
|
||||
assert bamboohr.parse(b'{"meta": {"totalCount": 0}, "result": []}', "configit") == []
|
||||
for body in (b"<html></html>", b"[]", b'{"result": null}'):
|
||||
with pytest.raises(ValueError):
|
||||
bamboohr.parse(body, "configit")
|
||||
|
||||
|
||||
def test_a_role_without_a_title_or_an_id_is_left_out() -> None:
|
||||
body = json.loads(_read("bamboohr.json"))
|
||||
body["result"][0]["jobOpeningName"] = " "
|
||||
body["result"][1]["id"] = None
|
||||
assert bamboohr.parse(json.dumps(body).encode(), "configit") == []
|
||||
|
||||
|
||||
def test_detail_reads_the_text_the_date_and_the_country() -> None:
|
||||
row = bamboohr.parse(_read("bamboohr.json"), "configit")[1]
|
||||
asked: list[tuple[str, Any]] = []
|
||||
url = "https://configit.bamboohr.com/careers/37/detail"
|
||||
found = bamboohr.detail(_get_of({url: _read("bamboohr-detail-37.json")}, asked),
|
||||
"configit", row)
|
||||
assert asked == [(url, {"Accept": "application/json"})]
|
||||
assert set(found) <= set(ats.DETAIL_FIELDS)
|
||||
assert found["posted"] == datetime(2026, 9, 23, tzinfo=UTC)
|
||||
assert found["location"] == "København Ø, Denmark"
|
||||
assert found["remote"] == "hybrid"
|
||||
text = found["description"]
|
||||
assert text.startswith("Our Global Marketing Team is looking for")
|
||||
assert "Skills & Experience" in text and "&" not in text and "<" not in text
|
||||
|
||||
|
||||
def test_detail_of_the_standing_invitation() -> None:
|
||||
row = bamboohr.parse(_read("bamboohr.json"), "configit")[0]
|
||||
url = "https://configit.bamboohr.com/careers/26/detail"
|
||||
found = bamboohr.detail(_get_of({url: _read("bamboohr-detail-26.json")}, []), "configit", row)
|
||||
assert found["posted"] == datetime(2025, 10, 10, tzinfo=UTC)
|
||||
assert found["description"].startswith("Hi, If there is currently no vacant position")
|
||||
assert "UK (remote)" in found["description"]
|
||||
|
||||
|
||||
def test_detail_refuses_an_answer_that_is_not_a_role() -> None:
|
||||
url = "https://configit.bamboohr.com/careers/37/detail"
|
||||
row = {"source_id": "37"}
|
||||
for body in (b"<html></html>", b'{"result": {}}', b"[]"):
|
||||
with pytest.raises(ValueError):
|
||||
bamboohr.detail(_get_of({url: body}, []), "configit", row)
|
||||
|
||||
|
||||
def test_the_board_and_its_details_are_read_through_the_app(
|
||||
monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(ats, "PAGE_DELAY", 0)
|
||||
base = "https://configit.bamboohr.com/careers"
|
||||
seen: list[str] = []
|
||||
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
seen.append(str(request.url))
|
||||
if request.url.path == "/careers/list":
|
||||
return httpx.Response(200, content=_read("bamboohr.json"))
|
||||
if request.url.path == "/careers/26/detail":
|
||||
return httpx.Response(404)
|
||||
assert request.headers["accept"] == "application/json"
|
||||
return httpx.Response(200, content=_read("bamboohr-detail-37.json"))
|
||||
|
||||
with httpx.Client(transport=httpx.MockTransport(handler)) as client:
|
||||
rows, complete = ats._fetch_rows(client, "bamboohr:configit")
|
||||
assert complete and len(rows) == 2 and seen == [f"{base}/list"]
|
||||
filled, done, failed = ats._read_details(client, "bamboohr:configit", rows, complete,
|
||||
set(), set())
|
||||
assert seen[1:] == [f"{base}/26/detail", f"{base}/37/detail"]
|
||||
# A 404 counts as read; the other role is filled from its own page.
|
||||
assert done == {"bamboohr:configit:26", "bamboohr:configit:37"} and failed == set()
|
||||
assert filled[0]["description"] == "" and filled[1]["location"] == "København Ø, Denmark"
|
||||
assert filled[1]["posted"] == datetime(2026, 9, 23, tzinfo=UTC)
|
||||
|
||||
|
||||
def test_the_slug_the_urls_and_the_allow_list() -> None:
|
||||
assert bamboohr.slug_ok("configit") and bamboohr.slug_ok("Configit")
|
||||
assert bamboohr.careers_url("configit") == "https://configit.bamboohr.com/careers"
|
||||
assert bamboohr.robots_page("configit") == "https://configit.bamboohr.com/careers"
|
||||
assert bamboohr.feed_url("Configit") == "https://configit.bamboohr.com/careers/list"
|
||||
allow = bamboohr.allowed("Configit")
|
||||
assert allow("configit.bamboohr.com") and allow("CONFIGIT.bamboohr.com")
|
||||
assert not allow("bamboohr.com") and not allow("other.bamboohr.com")
|
||||
assert not allow("configit.bamboohr.com.evil.example") and not allow("localhost")
|
||||
assert atshosts.HOSTS["bamboohr"] is bamboohr and ats.HOSTS["bamboohr"] == "BambooHR"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("slug", [
|
||||
"", "a@b", "a#b", "a?b", "..", "a/b", "a%2fb", "a:443", "a b", " a", "a\n", "a\r\n",
|
||||
"a.b", "127.0.0.1", "[::1]", "a_b", "2130706433.evil"])
|
||||
def test_a_hostile_slug_is_refused(slug: str) -> None:
|
||||
assert not bamboohr.slug_ok(slug)
|
||||
assert not ats.is_known_target(f"bamboohr:{slug}")
|
||||
|
||||
|
||||
def test_a_local_word_as_a_slug_only_reaches_bamboohrs_own_host() -> None:
|
||||
allow = bamboohr.allowed("localhost")
|
||||
assert allow("localhost.bamboohr.com") and not allow("localhost")
|
||||
|
||||
|
||||
def test_discovery_finds_the_subdomain_and_not_bamboohrs_own_hosts() -> None:
|
||||
page = ('<script src="https://Configit.bamboohr.com/js/embed.js"></script>'
|
||||
'<a href="https://www.bamboohr.com/">x</a><a href="https://app.bamboohr.com/x">y</a>'
|
||||
'<a href="https://resources.bamboohr.com/y">z</a>')
|
||||
assert [(h, s) for h, s, _ in discover.boards_in(page)] == [("bamboohr", "configit")]
|
||||
assert "bamboohr" not in {h for h, _ in discover._UNREADABLE if h not in atshosts.HOSTS}
|
||||
Reference in new issue
Block a user