Merge branch 'wp-e2-copies'

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 09:49:10 +02:00
commit 695d38c339
6 files changed
+336 -16

No files matched your search

+73 -5
View File
@@ -37,9 +37,9 @@ def dup_of(store: Store) -> dict[str, str | None]:
def test_a_board_under_several_ids_is_one_role_and_another_town_stays_apart(
store: Store) -> None:
"""SAP's repeats: three Garching rows are one kept role (the one with
the description) and two copies; New York is its own role."""
the description) and two copies; New York, listed by another host, is its own role."""
garching = [role("1", body=""), role("2"), role("3", body="")]
york = role("4", place="New York, NY, US")
york = role("4", place="New York, NY, US", board="greenhouse")
for item in (*garching, york):
store.upsert_role(item)
@@ -61,12 +61,80 @@ def test_a_search_copy_of_a_board_role_is_hidden_behind_the_board(store: Store)
assert dup_of(store) == {board.uid: None, search.uid: board.uid}
def test_berlin_and_munich_stay_two_roles(store: Store) -> None:
for item in (role("b", place="Berlin"), role("m", place="Munich")):
def kept_of(store: Store, *items: Item) -> str:
"""The uid of the one of these roles that is not a copy."""
found = dup_of(store)
(kept,) = [i.uid for i in items if found[i.uid] is None]
return kept
def test_berlin_and_munich_of_one_host_fold_into_one_role_with_two_places(
store: Store) -> None:
"""One posting per place on one host is one role that lists both places,
each with its own link; the count of copies does not show it as `x2`."""
berlin, munich = role("b", place="Berlin"), role("m", place="Munich")
for item in (berlin, munich):
store.upsert_role(item)
assert store.rebuild_dupes() == (1, 1, 1)
kept = kept_of(store, berlin, munich)
got = store.role(kept)
assert got is not None
assert sorted(p.text for p in got.places) == ["Berlin", "Munich"]
assert sorted(p.url for p in got.places if p.url) in (
["https://jobs.example/b"], ["https://jobs.example/m"])
assert got.copies == []
(row,) = store.roles_page()
assert (row.uid, row.place, row.copies) == (kept, f"{got.places[0].text} +1", 0)
def test_places_of_two_hosts_or_two_different_texts_stay_apart(store: Store) -> None:
a = role("a", place="Berlin", body="Build payment services in Kotlin for our bank " * 5)
b = role("b", place="Munich", body="Sell cloud contracts to enterprise buyers " * 5)
c = role("c", place="Hamburg", board="greenhouse", body=a.body)
for item in (a, b, c):
store.upsert_role(item)
assert store.rebuild_dupes() == (0, 0, 0)
def own_and_copy_places(store: Store, uid: str) -> list[tuple[str, bool]]:
got = store.role(uid)
assert got is not None
return sorted((p.text, bool(p.url)) for p in got.places)
def test_a_place_copy_closing_or_its_board_off_takes_its_place_away(store: Store) -> None:
from app.jobs.sources import set_fetch
sub = store.add_subscription("ats", "successfactors:sap", label="SAP")
items = [role("b", place="Berlin"), role("m", place="Munich"), role("k", place="Kiel")]
for item in items:
store.upsert_role(item, sub)
store.rebuild_dupes()
kept = kept_of(store, *items)
assert [t for t, _ in own_and_copy_places(store, kept)] == ["Berlin", "Kiel", "Munich"]
closing = next(i for i in items if i.uid != kept)
with sqlite3.connect(store.path) as conn:
conn.execute("UPDATE roles SET closed_at = '2026-09-25' WHERE uid = ?", (closing.uid,))
store.rebuild_dupes()
assert len(own_and_copy_places(store, kept)) == 2
assert store.rebuild_dupes().changed == 0
set_fetch(store, sub.id, False)
assert set(dup_of(store).values()) == {None}
assert not any(url for _, url in own_and_copy_places(store, kept))
def test_a_repull_keeps_the_copies_places(store: Store) -> None:
items = [role("b", place="Berlin"), role("m", place="Munich")]
for item in items:
store.upsert_role(item)
store.rebuild_dupes()
kept = kept_of(store, *items)
store.upsert_role(next(i for i in items if i.uid == kept))
assert [t for t, _ in own_and_copy_places(store, kept)] == ["Berlin", "Munich"]
def test_closing_the_kept_role_hands_the_group_on_and_a_closed_copy_is_cleared(
store: Store) -> None:
first, second, third = role("1", day=18), role("2", day=19), role("3", day=20)
@@ -129,7 +197,7 @@ def test_a_closed_kept_role_hands_its_read_and_vote_to_the_next(store: Store) ->
def test_a_copy_is_left_out_of_the_feed_counts_and_model_stages(store: Store) -> None:
kept, copy, other = role("1", day=18), role("2", day=19), role("3", place="Berlin")
kept, copy, other = role("1", day=18), role("2", day=19), role("3", place="Berlin", board="greenhouse")
for item in (kept, copy, other):
store.upsert_role(item)
store.set_tags(item.uid, ["python"])