Pin the per-office fold within one country: two offices in two countries are two roles, and a role in several Danish cities leads with the agent's town

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-10-06 13:58:41 +02:00
1 parent 02ea191b53
commit f141cffc3c
1 file changed
+21 -18
+21 -18
View File
@@ -103,10 +103,11 @@ def test_berlin_and_munich_of_one_host_fold_into_one_role_with_two_places(
assert (row.uid, row.place, row.copies) == (kept, f"{got.places[0].text} +1", 0)
def test_a_place_copy_in_europe_meets_a_europe_gate_for_its_kept_role(store: Store) -> None:
"""OpenAI posts one role in San Francisco and in Dublin. The kept role
holds both places, so a Europe gate and the Place filter find it through
Dublin, though `roles.place` and `roles.country` are San Francisco's."""
def test_a_posting_per_office_in_two_countries_is_two_roles(store: Store) -> None:
"""OpenAI posts one role in San Francisco and in Dublin. The fold keeps
to one country (ADR 1.4), so each is a role of its own: a Europe gate
takes Dublin and rejects San Francisco, and the Place filter finds
Dublin alone."""
from app import prep
from app.models import Gate
sf = role("sf", company="OpenAI", place="San Francisco", country="US", board="ashby")
@@ -114,10 +115,11 @@ def test_a_place_copy_in_europe_meets_a_europe_gate_for_its_kept_role(store: Sto
for item in (sf, dublin):
store.upsert_role(item)
prep.run(store)
kept = kept_of(store, sf, dublin)
assert dup_of(store) == {sf.uid: None, dublin.uid: None}
agent = store.save_agent("A", gates=[Gate(field="country", values=["FR", "IE", "EU"])])
assert {c.uid: c.gates for c in store.score_candidates(agent.id, agent.gates)} == {kept: [1]}
assert {r.uid for r in store.roles(places=["country:IE"], by_score=False)} == {kept}
assert {c.uid: c.gates for c in store.score_candidates(agent.id, agent.gates)} == {
sf.uid: [0], dublin.uid: [1]}
assert {r.uid for r in store.roles(places=["country:IE"], by_score=False)} == {dublin.uid}
def test_places_of_two_hosts_or_two_different_texts_stay_apart(store: Store) -> None:
@@ -305,30 +307,31 @@ def test_switching_a_board_off_shows_its_roles_copies_at_once(store: Store) -> N
def test_a_role_in_several_cities_leads_with_the_one_nearest_the_agent(store: Store) -> None:
"""Mistral posts one role per city. For an agent kept to Europe the kept
Montréal role leads with Paris, in the row and the reader, and opens the
Paris copy; without an agent the host's order stands."""
"""A Danish company posts one role per city. For an agent whose towns
hold Copenhagen the kept Aarhus role leads with Copenhagen, in the row
and the reader, and opens the Copenhagen copy; without an agent the
host's order stands."""
from app import prep
from app.models import Gate
items = [role(c, company="Mistral AI", place=p, board="ashby") for c, p in (
("mtl", "Montréal"), ("nyc", "New York"), ("par", "Paris"))]
items = [role(c, company="Danske", place=p, board="ashby") for c, p in (
("aar", "Aarhus"), ("bil", "Billund"), ("cph", "Copenhagen"))]
for item in items:
store.upsert_role(item)
prep.run(store)
kept = kept_of(store, *items)
agent = store.save_agent("A", gates=[
Gate(field="country", values=["FR", "DK", "EU"], mode="require"),
Gate(field="country", values=["DK"], mode="any")])
Gate(field="place", values=["copenhagen"], mode="any")])
got = store.role(kept, agent.id)
assert got is not None
own = next(p.text for p in got.places if not p.url)
assert own != "Paris"
assert (got.lead_place, got.lead_url) == ("Paris", "https://jobs.example/par")
assert got.places[0].text == "Paris"
assert own != "Copenhagen"
assert (got.lead_place, got.lead_url) == ("Copenhagen", "https://jobs.example/cph")
assert got.places[0].text == "Copenhagen"
(row,) = store.roles_page(agent=agent.id, by_score=False)
assert (row.place, row.lead_place, row.lead_url) == ("Paris +2", "Paris", got.lead_url)
assert row.place_texts[0] == "Paris" and len(row.place_texts) == 3
assert (row.place, row.lead_place, row.lead_url) == ("Copenhagen +2", "Copenhagen", got.lead_url)
assert row.place_texts[0] == "Copenhagen" and len(row.place_texts) == 3
plain = store.role(kept)
assert plain is not None