SPB Git forge
28commits 1branches 0releases
7.7 MBsize
maindefault branch
10 days agolast push
Python 66.3% TypeScript 22.7% JavaScript 8.6% HTML 1.4% CSS 0.7%
5.4 KB · 97 lines python
Raw Blame History
1from __future__ import annotations23from conftest import fixture_path45from companyatlas.fetch import file_result6from companyatlas.sdk import connector as C78BASE = "https://www.acme-cloud.example"9CFG = {"canonical_domain": "acme-cloud.example"}101112def _run(surface: str, name: str, path: str):  # type: ignore[no-untyped-def]13    url = BASE + path14    return C.get("generic-html-v1").extract({"url": url, "surface": surface, "config": CFG}, file_result(fixture_path("generic_html", name), url=url))151617def test_pricing_plans() -> None:18    ex = _run("pricing", "pricing.html", "/pricing")19    plans = {p.plan_name: p for p in ex.plans}20    assert set(plans) == {"Starter", "Pro", "Enterprise"}21    assert plans["Starter"].price == 29 and plans["Starter"].currency == "USD" and plans["Starter"].billing_period == "month"22    assert plans["Pro"].unit == "user" and "SSO & SAML" in plans["Pro"].features23    assert plans["Enterprise"].contact_sales and plans["Enterprise"].billing_period == "contact" and plans["Enterprise"].price is None24    assert {d.surface.value for d in ex.discovered} >= {"careers", "docs", "legal_terms", "feed"}252627def test_leadership_people() -> None:28    ex = _run("leadership", "leadership.html", "/about/leadership")29    people = {p.name: p for p in ex.people}30    assert people["Jane Doe"].role_category == "ceo" and people["Jane Doe"].is_executive31    assert people["María García-López"].role_category == "cto"32    assert people["Tom O'Neill"].role_category == "vp" and not people["Tom O'Neill"].is_executive33    assert people["Samuel Adebayo"].role_category == "chair" and people["Lin Wei"].role_category == "board"34    assert "Meet the people" not in people353637def test_locations_never_invent() -> None:38    ex = _run("locations", "locations.html", "/company/locations")39    locs = {loc.name: loc for loc in ex.locations}40    assert locs["San Francisco (Headquarters)"].kind == "headquarters" and locs["San Francisco (Headquarters)"].country == "US"41    assert locs["San Francisco (Headquarters)"].address_text.startswith("548 Market Street")42    assert locs["Toronto"].country == "CA" and locs["Toronto"].region == "ON" and locs["Toronto"].address_text is None43    assert locs["Dublin Data Center"].kind == "data_center" and locs["Dublin Data Center"].country == "IE"44    assert locs["London"].city == "London" and locs["London"].country == "GB"454647def test_newsroom_items_with_dates() -> None:48    ex = _run("newsroom", "newsroom.html", "/news")49    assert len(ex.news) == 450    assert ex.news[0].title.startswith("Acme launches Atlas AI") and ex.news[0].published_at.date().isoformat() == "2026-09-10"51    assert ex.news[1].published_at.date().isoformat() == "2026-08-28"      # from <time datetime>52    assert all(n.category == "press" for n in ex.news)53    assert all(not n.title.startswith(("September", "August")) for n in ex.news)545556def test_careers_html_jobs_and_removed_semantics() -> None:57    ex = _run("careers", "careers.html", "/careers")58    titles = [j.title for j in ex.jobs]59    assert titles == ["Senior Backend Engineer", "Machine Learning Engineer", "Account Executive, EMEA", "People Operations Lead", "Product Designer"]60    ml = ex.jobs[1]61    assert ml.remote is True and ml.country == "US" and ml.department == "Engineering"62    assert ex.jobs[0].city == "Toronto" and ex.jobs[0].country == "CA" and ex.jobs[0].seniority == "senior"63    assert ex.jobs[4].country is None                                      # "San Francisco, CA" — no guess64    assert [b.kind for b in ex.blocks].count("job_listing") == 565    ex2 = _run("careers", "careers_v2.html", "/careers")66    assert "AI Research Scientist" in [j.title for j in ex2.jobs] and "People Operations Lead" not in [j.title for j in ex2.jobs]676869def test_careers_jsonld_jobs() -> None:70    ex = _run("careers", "careers_jsonld.html", "/jobs")71    assert [j.external_id for j in ex.jobs] == ["REQ-501", "REQ-502"]72    assert ex.jobs[0].country == "CA" and ex.jobs[0].city == "Toronto"73    assert ex.jobs[1].remote is True and ex.jobs[1].salary_min == 180000 and ex.jobs[1].salary_currency == "USD"74    via_connector = C.get("jsonld-jobs-v1").extract({"url": BASE + "/jobs", "surface": "careers", "config": CFG}, file_result(fixture_path("generic_html", "careers_jsonld.html"), url=BASE + "/jobs"))75    assert len(via_connector.jobs) == 2 and via_connector.meta["structured"]767778def test_non_listing_page_yields_no_jobs() -> None:79    ex = _run("careers", "legal_terms.html", "/careers")80    assert ex.jobs == []                                                   # < 3 job-like anchors → untrusted → nothing818283def test_homepage_products_and_discovery() -> None:84    home = _run("homepage", "homepage.html", "/")85    assert home.title.startswith("Acme Cloud") and home.language == "en"86    found = {d.surface.value for d in home.discovered}87    assert {"pricing", "careers", "newsroom", "leadership", "locations", "investor_relations", "changelog", "legal_terms", "legal_privacy", "feed", "docs"} <= found88    assert all(d.confidence >= 0.55 for d in home.discovered)89    prods = _run("products", "homepage.html", "/")90    assert [p.name for p in prods.products] == ["Atlas Metrics", "Atlas Logs", "Atlas Traces"]919293def test_legal_is_text_and_blocks_only() -> None:94    ex = _run("legal_terms", "legal_terms.html", "/legal/terms")95    assert not (ex.jobs or ex.people or ex.plans or ex.locations or ex.news or ex.products)96    assert "Limitation of liability" in ex.text and [b.kind for b in ex.blocks].count("heading") >= 597