Judge an employer known only from a search; the Companies list says "from job boards"
Store.set_affinity creates a minimal company row (key, and the name its roles give most often) for a key with roles and no row, so a Jobindex or Adzuna employer can be hidden or liked; the reader draws the control for any role with a company_key and reloads the company list after the first change. /api/companies derives from_search: no ats subscription (detached included) and no ats, careers_url or domain. companies.js labels it "from job boards" and keeps it out of "Not readable yet". Co-Authored-By: Claude Opus <noreply@anthropic.com>
This commit is contained in:
1 parent
91d15fcc7d
commit
b2c8c08f7f
6 files changed
+78
-15
No files matched your search
+36
-2
@@ -389,7 +389,7 @@ def test_companies_lists_board_and_open_role_count(
|
||||
sub = store.add_subscription("ats", "greenhouse:acme", company="Acme", board="greenhouse")
|
||||
store.add_company("Acme", key="acme", ats="greenhouse", country="DK")
|
||||
store.upsert_role(posting("1", company="Acme"), sub)
|
||||
store.add_company("Other", key="other") # no board found
|
||||
store.add_company("Other", key="other", domain="other.example") # no board found
|
||||
store.add_company("Novo", key="novo", ats="successfactors", # followed, not readable
|
||||
careers_url="https://novo.example/careers")
|
||||
|
||||
@@ -399,13 +399,47 @@ def test_companies_lists_board_and_open_role_count(
|
||||
assert row == {"key": "acme", "name": "Acme", "board": "greenhouse",
|
||||
"subscription_id": sub.id, "on": True, "affinity": 0, "open_roles": 1,
|
||||
"ats": "greenhouse", "ats_slug": "", "careers_url": "",
|
||||
"country": "DK", "failing_since": "", "failing_reason": ""}
|
||||
"country": "DK", "failing_since": "", "failing_reason": "",
|
||||
"from_search": False}
|
||||
[other] = [c for c in res.json() if c["key"] == "other"]
|
||||
assert (other["board"], other["subscription_id"], other["on"], other["ats"]) == (
|
||||
"", None, None, "")
|
||||
[novo] = [c for c in res.json() if c["key"] == "novo"]
|
||||
assert (novo["board"], novo["subscription_id"], novo["ats"], novo["careers_url"]) == (
|
||||
"", None, "successfactors", "https://novo.example/careers")
|
||||
assert not any(c["from_search"] for c in res.json())
|
||||
|
||||
|
||||
def test_judging_a_company_known_only_from_a_search_creates_its_row(
|
||||
client: TestClient, store: Store) -> None:
|
||||
"""Jobindex and Adzuna employers have roles and no company row. The first
|
||||
affinity change makes a minimal one, named by its roles, which the
|
||||
Companies list marks `from_search`, unlike a followed company without a
|
||||
board, and a company whose board was detached."""
|
||||
store.save_agent("A")
|
||||
search = store.add_subscription("search", "jobindex:cph", label="cph", board="jobindex")
|
||||
for i, name in enumerate(("Novo Nordisk A/S", "Novo Nordisk A/S", "NOVO NORDISK A/S")):
|
||||
item = posting(f"n{i}", company=name)
|
||||
item.source = "search"
|
||||
store.upsert_role(item, search)
|
||||
key = "novo-nordisk"
|
||||
assert store.company(key) is None
|
||||
|
||||
res = client.post(f"/api/companies/{key}/affinity", json={"affinity": -1})
|
||||
assert res.status_code == 200, res.text
|
||||
assert (res.json()["name"], res.json()["affinity"]) == ("Novo Nordisk A/S", -1)
|
||||
assert client.post("/api/companies/nobody/affinity", json={"affinity": 1}).status_code == 404
|
||||
|
||||
store.add_company("Pleo", key="pleo", domain="pleo.io") # followed, no board found
|
||||
sub = store.add_subscription("ats", "lever:gone", company="Gone", board="lever")
|
||||
store.add_company("Gone", key="gone")
|
||||
store.set_company_board("gone", "") # detached
|
||||
assert not store.subscription(sub.id).show # type: ignore[union-attr]
|
||||
rows = {c["key"]: c for c in client.get("/api/companies").json()}
|
||||
assert rows["gone"]["board"] == ""
|
||||
assert rows[key]["from_search"] and rows[key]["open_roles"] == 3
|
||||
assert (rows[key]["board"], rows[key]["ats"], rows[key]["careers_url"]) == ("", "", "")
|
||||
assert not rows["pleo"]["from_search"] and not rows["gone"]["from_search"]
|
||||
|
||||
|
||||
def test_companies_say_since_when_a_board_fails(client: TestClient, store: Store,
|
||||
|
||||
Reference in new issue
Block a user