Add migration 26, roles.posting_url, kept across pulls and carried on the row and its copies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
54b56ac370
commit
d168d9eb6c
10 files changed
+76
-19
No files matched your search
@@ -148,7 +148,7 @@ def test_migration_20_seeds_an_old_file_and_leaves_collisions(tmp_path: Path) ->
|
||||
"VALUES (?, ?, '', '')", (key, name))
|
||||
conn.execute("PRAGMA user_version = 19")
|
||||
reopened = Store(path)
|
||||
assert reopened.migrations_applied == [20, 21, 22, 23, 24, 25]
|
||||
assert reopened.migrations_applied == [20, 21, 22, 23, 24, 25, 26]
|
||||
assert reopened.duplicate_companies() == [("orsted", ["orsted", "ørsted"])]
|
||||
assert len(reopened.companies()) == 3
|
||||
|
||||
@@ -186,7 +186,7 @@ def test_migration_21_tags_the_favourites_and_the_boards_that_read_all_roles(tmp
|
||||
conn.execute("ALTER TABLE companies DROP COLUMN all_countries")
|
||||
conn.execute("PRAGMA user_version = 20")
|
||||
reopened = Store(path)
|
||||
assert reopened.migrations_applied == [21, 22, 23, 24, 25]
|
||||
assert reopened.migrations_applied == [21, 22, 23, 24, 25, 26]
|
||||
# The tag of 21 is All countries and All roles since 24.
|
||||
tagged = {"mistral-ai": 1, "acme": 0, "black-forest-labs": 1, "liked": 0}
|
||||
assert {c.key: c.all_roles for c in reopened.companies()} == tagged
|
||||
|
||||
@@ -246,7 +246,7 @@ def test_a_v17_file_gains_dup_of_with_its_first_rebuild(tmp_path: Path) -> None:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [18, 19, 20, 21, 22, 23, 24, 25]
|
||||
assert migrated.migrations_applied == [18, 19, 20, 21, 22, 23, 24, 25, 26]
|
||||
assert dup_of(migrated) == {first.uid: None, second.uid: first.uid}
|
||||
with sqlite3.connect(path) as conn:
|
||||
assert conn.execute("SELECT 1 FROM sqlite_master WHERE name = 'idx_roles_dup_of'"
|
||||
|
||||
@@ -437,7 +437,7 @@ def test_migration_23_gives_every_agent_no_terms(tmp_path: Path) -> None:
|
||||
conn.execute("ALTER TABLE agents DROP COLUMN fetch_terms")
|
||||
conn.execute("PRAGMA user_version = 22")
|
||||
migrated = Store(path)
|
||||
assert migrated.migrations_applied == [23, 24, 25]
|
||||
assert migrated.migrations_applied == [23, 24, 25, 26]
|
||||
assert migrated.agents()[0].fetch_terms == []
|
||||
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ def test_migration_24_splits_the_tag_and_moves_terms_off(tmp_path: Path) -> None
|
||||
conn.execute("UPDATE companies SET all_roles=1 WHERE key='mistral-ai'")
|
||||
conn.execute("PRAGMA user_version = 23")
|
||||
migrated = Store(path)
|
||||
assert migrated.migrations_applied == [24, 25]
|
||||
assert migrated.migrations_applied == [24, 25, 26]
|
||||
flags = {c.key: (c.all_countries, c.all_roles) for c in migrated.companies()}
|
||||
assert flags == {"mistral-ai": (1, 1), "acme": (0, 1), "plain": (0, 0)}
|
||||
params = {s.target: s.params for s in migrated.subscriptions(source="ats")}
|
||||
|
||||
+1
-1
@@ -314,7 +314,7 @@ def test_migration_22_fills_the_host_words_from_raw(tmp_path: Path) -> None:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [22, 23, 24, 25]
|
||||
assert migrated.migrations_applied == [22, 23, 24, 25, 26]
|
||||
one = row(migrated, "1")
|
||||
assert (one["seniority_host"], one["employment_host"], one["remote_host"],
|
||||
one["country_host"]) == ("senior", "full_time", "true", "DK")
|
||||
|
||||
+37
-7
@@ -70,7 +70,7 @@ def test_schema_creates_on_an_empty_file(tmp_path: Path) -> None:
|
||||
"application_events", "agents", "scores", "state"} <= tables
|
||||
assert "idx_roles_cluster" in indexes
|
||||
assert store.migrations_applied == []
|
||||
assert LATEST == 25
|
||||
assert LATEST == 26
|
||||
# A second open finds it current and applies nothing.
|
||||
assert Store(path).migrations_applied == []
|
||||
|
||||
@@ -187,7 +187,7 @@ def test_a_v14_file_gains_the_watchlist_columns_and_leaves_companies_unrated(
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
|
||||
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]
|
||||
acme = migrated.company("acme")
|
||||
assert acme is not None
|
||||
assert (acme.ats, acme.careers_url) == ("teamtailor", "https://a.example")
|
||||
@@ -392,7 +392,7 @@ def test_v14_makes_each_intent_the_agents_one_prompt_with_its_vector(tmp_path: P
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
|
||||
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]
|
||||
assert migrated.agent(backend.id).prompts == [ # type: ignore[union-attr]
|
||||
Prompt(name="Backend", text="python backend")]
|
||||
assert migrated.agent(blank.id).prompts == [] # type: ignore[union-attr]
|
||||
@@ -416,7 +416,7 @@ def test_v16_gives_a_company_no_reason_and_keeps_its_row(tmp_path: Path) -> None
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
|
||||
assert migrated.migrations_applied == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]
|
||||
acme = migrated.company("acme")
|
||||
assert acme is not None
|
||||
assert (acme.careers_url, acme.notes, acme.hand_reason) == (
|
||||
@@ -445,7 +445,7 @@ def test_v17_folds_every_place_and_levels_the_titles_extract_has_not_read(
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [17, 18, 19, 20, 21, 22, 23, 24, 25]
|
||||
assert migrated.migrations_applied == [17, 18, 19, 20, 21, 22, 23, 24, 25, 26]
|
||||
with sqlite3.connect(path) as conn:
|
||||
rows = {uid: (fold, level) for uid, fold, level in conn.execute(
|
||||
"SELECT uid, place_fold, seniority FROM roles")}
|
||||
@@ -688,7 +688,7 @@ def test_v19_gives_every_role_its_places_and_splits_its_level(tmp_path: Path) ->
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [19, 20, 21, 22, 23, 24, 25]
|
||||
assert migrated.migrations_applied == [19, 20, 21, 22, 23, 24, 25, 26]
|
||||
assert [p.name for p in migrated.role_places(joined.uid)] == ["Copenhagen", "Malmö"]
|
||||
assert [p.name for p in migrated.role_places(detailed.uid)] == ["Aarhus"]
|
||||
assert migrated.role_places(stated.uid) == []
|
||||
@@ -730,7 +730,7 @@ def test_v25_clears_the_model_levels_the_ladder_splits_and_sets_the_level(
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [25]
|
||||
assert migrated.migrations_applied == [25, 26]
|
||||
with sqlite3.connect(path) as conn:
|
||||
found = {sid: rest for sid, *rest in conn.execute(
|
||||
"SELECT source_id, seniority_model, seniority_stated, seniority_title, seniority "
|
||||
@@ -738,6 +738,36 @@ def test_v25_clears_the_model_levels_the_ladder_splits_and_sets_the_level(
|
||||
assert found == {sid: list(after) for sid, (_, after) in cases.items()}
|
||||
|
||||
|
||||
def test_v26_adds_posting_url_empty_and_runs_twice_without_harm(tmp_path: Path) -> None:
|
||||
path = tmp_path / "v25.db"
|
||||
store = Store(path)
|
||||
upsert(store, posting("a"))
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("ALTER TABLE roles DROP COLUMN posting_url")
|
||||
conn.execute("PRAGMA user_version = 25")
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [26]
|
||||
role = migrated.role(posting("a").uid)
|
||||
assert role is not None and role.posting_url == ""
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 25") # the column is there already
|
||||
assert Store(path).migrations_applied == [26]
|
||||
|
||||
|
||||
def test_a_pull_keeps_the_posting_url(store: Store) -> None:
|
||||
upsert(store, posting("a"))
|
||||
uid = posting("a").uid
|
||||
assert store.set_posting_url(uid, "https://careers.example/jobs/1")
|
||||
assert not store.set_posting_url("nope", "https://careers.example/jobs/1")
|
||||
upsert(store, posting("a")) # the next pull reads the same role again
|
||||
role = store.role(uid)
|
||||
assert role is not None and role.posting_url == "https://careers.example/jobs/1"
|
||||
row = next(r for r in store.roles_page() if r.uid == uid)
|
||||
assert row.posting_url == "https://careers.example/jobs/1"
|
||||
|
||||
|
||||
def test_upsert_unpacks_raw_and_keeps_filled_columns(store: Store) -> None:
|
||||
upsert(store, posting(place="Berlin", remote=True, salary_min="80000",
|
||||
salary_max=95000, currency="EUR", department="Eng"))
|
||||
|
||||
+3
-2
@@ -1224,7 +1224,7 @@ def test_list_roles_serves_the_row_projection_and_not_the_big_columns(
|
||||
assert set(row) == {
|
||||
"uid", "company_key", "company", "title", "place", "country", "remote", "function",
|
||||
"seniority", "salary_min", "salary_max", "currency", "salary_text", "salary_state",
|
||||
"original_url", "posted_at", "score", "gated_reason", "prompt", "vote",
|
||||
"original_url", "posting_url", "posted_at", "score", "gated_reason", "prompt", "vote",
|
||||
"voted_at", "read_at", "tags", "excerpt", "copies",
|
||||
}
|
||||
assert row["uid"] == uid
|
||||
@@ -1734,7 +1734,8 @@ def test_a_kept_role_lists_its_copies_and_a_copy_names_its_kept_role(
|
||||
assert kept["dup_of"] is None
|
||||
assert kept["copies"] == [{
|
||||
"uid": search.uid, "host": "jobindex", "place": "Ballerup, Denmark",
|
||||
"original_url": search.location, "posted_at": kept["copies"][0]["posted_at"]}]
|
||||
"original_url": search.location, "posting_url": "",
|
||||
"posted_at": kept["copies"][0]["posted_at"]}]
|
||||
copy = client.get(f"/api/roles/{search.uid}").json()
|
||||
assert copy["dup_of"] == board.uid and copy["copies"] == []
|
||||
|
||||
|
||||
Reference in new issue
Block a user