Fold per-place copies of one host into one role that lists every place with its own link
The reader shows every place, each linked to its copy, and the teaser marked as a short description when there is no text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3adafd8950
commit
3d1fed7c0e
6 files changed
+336
-16
No files matched your search
+48
-1
@@ -12,7 +12,15 @@ if str(ROOT) not in sys.path:
|
||||
|
||||
import pytest # noqa: E402
|
||||
|
||||
from app.dupes import Copy, assign, keep_order, same_posting # noqa: E402
|
||||
from app.dupes import ( # noqa: E402
|
||||
Copy,
|
||||
assign,
|
||||
fold,
|
||||
keep_order,
|
||||
place_line,
|
||||
same_posting,
|
||||
similar,
|
||||
)
|
||||
from app.places import towns # noqa: E402
|
||||
|
||||
|
||||
@@ -194,3 +202,42 @@ def test_a_row_without_a_place_never_bridges_two_countries():
|
||||
assert got == {"a": None, "b": "a", "c": "a", "d": None, "e": None}
|
||||
assert not same_posting(cp("a", country="EU", place="Belgium"),
|
||||
cp("b", country="EU", place="Netherlands"))
|
||||
|
||||
|
||||
def pc(uid: str, place: str, text: str = "", host: str = "greenhouse", url: str = "u",
|
||||
title: str = "engineer") -> Copy:
|
||||
return Copy(uid, "acme", title, "DE", place, host, bool(text), None, text, url or "")
|
||||
|
||||
|
||||
def test_one_posting_per_place_folds_into_the_first_and_only_within_a_host() -> None:
|
||||
text = "We build the payment platform for our bank customers in Kotlin."
|
||||
got = fold([pc("b", "Berlin", text), pc("m", "Munich", text), pc("h", "Hamburg", text),
|
||||
pc("x", "Kiel", text, host="lever")])
|
||||
assert got.dup_of == {"b": None, "m": "b", "h": "b", "x": None}
|
||||
assert got.placed == {"m", "h"}
|
||||
|
||||
|
||||
def test_folding_needs_the_same_title_a_link_and_texts_that_can_be_one_job() -> None:
|
||||
a = "Build payment services in Kotlin for our bank customers and their teams."
|
||||
b = "Negotiate enterprise cloud contracts with procurement and legal buyers."
|
||||
got = fold([pc("1", "Berlin", a), pc("2", "Munich", b), pc("3", "Hamburg", a, url=""),
|
||||
pc("4", "Kiel", a, title="manager")])
|
||||
assert got.dup_of == {"1": None, "2": None, "3": None, "4": None}
|
||||
assert fold([pc("1", "Berlin", a), pc("2", "Munich", "")]).placed == {"2"}
|
||||
|
||||
|
||||
def test_a_copy_of_a_folded_row_follows_it_to_the_new_kept_role() -> None:
|
||||
"""Berlin is kept over Munich; a second Munich row that was Munich's copy
|
||||
now points at Berlin, and is not a place of its own."""
|
||||
text = "We build the payment platform for our bank customers in Kotlin."
|
||||
same = fold([pc("b", "Berlin", text), pc("m", "Munich", text),
|
||||
pc("m2", "Munich, Germany", text)])
|
||||
assert same.dup_of == {"b": None, "m": "b", "m2": "b"}
|
||||
assert same.placed == {"m"} # m2 is m's own copy, not another place
|
||||
|
||||
|
||||
def test_similar_and_place_line() -> None:
|
||||
assert similar("", "anything at all") and similar("a job in Kotlin", "a job in Kotlin")
|
||||
assert not similar("sell cloud contracts to buyers", "build kotlin payment services")
|
||||
assert place_line(["Berlin", "Munich", "Berlin", "Hamburg"]) == "Berlin +2"
|
||||
assert place_line(["Berlin", " "]) == "Berlin" and place_line([]) == ""
|
||||
Reference in new issue
Block a user