List unlinked places and unmapped words under Sources, fix them in code with the unmapped skill
Settings > Sources > Unmapped shows the place texts no place resolves, with their roles' countries and companies, and the host words no table maps, and copies both as text. Prep fingerprints places.seed(), so a town or spelling added to the code is seeded and every open role is mapped again at the next prep. app prep unlinked lists the places on the command line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ae978594b4
commit
06ff9f549b
13 files changed
+313
-43
No files matched your search
@@ -319,6 +319,16 @@ def test_unresolved_texts_are_listed_most_roles_first(store: Store) -> None:
|
||||
assert store.unresolved_places(limit=1) == [("oberkochen", "Oberkochen", 2)]
|
||||
|
||||
|
||||
def test_unlinked_texts_carry_their_roles_countries_and_companies(store: Store) -> None:
|
||||
upsert(store, posting("1", place="Oberkochen", company="Zeiss", country="DE"))
|
||||
upsert(store, posting("2", place="Oberkochen", company="Zeiss"))
|
||||
upsert(store, posting("3", place="Oberkochen; Remote", company="Hensoldt", country="DE"))
|
||||
upsert(store, posting("4", place="Remote"))
|
||||
assert store.unlinked_places() == [{
|
||||
"fold": "oberkochen", "text": "Oberkochen", "roles": 3,
|
||||
"countries": [["DE", 2], ["", 1]], "companies": ["Zeiss", "Hensoldt"]}]
|
||||
|
||||
|
||||
def test_an_alias_links_what_it_names(store: Store) -> None:
|
||||
upsert(store, posting("1", place="Kbh. K"))
|
||||
upsert(store, posting("2", place="Copenhagen"))
|
||||
|
||||
@@ -273,6 +273,21 @@ def test_a_changed_table_maps_every_open_role_again_without_a_pull(store: Store)
|
||||
assert row(store, "2")["seniority"] == "staff"
|
||||
|
||||
|
||||
def test_a_town_added_to_the_code_is_linked_at_the_next_prep(
|
||||
store: Store, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
store.upsert_role(item("1", places=[{"text": "Überlingen", "remote": None}]))
|
||||
prep.run(store, tables=TABLES)
|
||||
assert [p["text"] for p in store.unlinked_places()] == ["Überlingen"]
|
||||
assert row(store, "1")["country"] == ""
|
||||
|
||||
monkeypatch.setitem(models._CITIES, "uberlingen", "DE")
|
||||
done = prep.run(store, tables=TABLES)
|
||||
assert done.remapped
|
||||
assert store.unlinked_places() == []
|
||||
assert row(store, "1")["country"] == "DE"
|
||||
assert store.state[prep.STATE] == prep.fingerprint(TABLES)
|
||||
|
||||
|
||||
def test_prep_folds_the_copies(store: Store) -> None:
|
||||
for n in ("1", "2"):
|
||||
store.upsert_role(item(n, place="Aarhus"))
|
||||
@@ -325,6 +340,9 @@ def test_app_prep_runs_and_lists_the_unmapped_words(
|
||||
assert json.loads(capsys.readouterr().out)["read"] == 1
|
||||
assert cli.main(["-c", str(path), "prep", "unmapped"]) == 0
|
||||
assert capsys.readouterr().out.split() == ["seniority", "acme", "1", "grand", "poobah"]
|
||||
Store(tmp_path / "roledesk.db").upsert_role(item("2", place="Überlingen"))
|
||||
assert cli.main(["-c", str(path), "prep", "unlinked"]) == 0
|
||||
assert capsys.readouterr().out.split() == ["1", "Überlingen", "-:1", "Acme"]
|
||||
assert cli.main(["-c", str(path), "prep", "--remap"]) == 0
|
||||
assert json.loads(capsys.readouterr().out)["remapped"] is True
|
||||
|
||||
@@ -345,6 +363,22 @@ def test_the_api_lists_the_unmapped_words(tmp_path: Path) -> None:
|
||||
[("employment", "acme", "zero hours", 1)]
|
||||
|
||||
|
||||
def test_the_api_lists_the_unlinked_places(tmp_path: Path) -> None:
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.config import Config, ServerConfig
|
||||
from app.main import create_app
|
||||
|
||||
app = create_app(Config(server=ServerConfig(host="127.0.0.1", port=0),
|
||||
database=tmp_path / "roledesk.db"))
|
||||
app.state.store.upsert_role(item("1", place="Überlingen", country="DE"))
|
||||
prep.run(app.state.store, tables=TABLES)
|
||||
with TestClient(app) as client:
|
||||
found = client.get("/api/prep/unlinked").json()
|
||||
assert found == [{"fold": "uberlingen", "text": "Überlingen", "roles": 1,
|
||||
"countries": [["DE", 1]], "companies": ["Acme"]}]
|
||||
|
||||
|
||||
# ------------------------------------------------------------- the tables
|
||||
|
||||
def test_every_host_table_maps_into_its_vocabulary() -> None:
|
||||
|
||||
+1
-1
@@ -832,7 +832,7 @@ def test_every_section_of_the_sources_page_exists(client: TestClient) -> None:
|
||||
data-section>` on the page, which is what sources.js shows one of, and
|
||||
the log at the end of Runs still answers `#messages`."""
|
||||
anchors = [anchor for anchor, _ in SECTIONS["/settings/sources"]]
|
||||
assert anchors == ["job-boards", "company-boards", "runs"]
|
||||
assert anchors == ["job-boards", "company-boards", "runs", "unmapped"]
|
||||
page = client.get("/settings/sources").text
|
||||
assert page.count("data-section>") == len(anchors)
|
||||
for anchor in anchors:
|
||||
|
||||
Reference in new issue
Block a user