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
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user