Merge branch 'r2-backend'
# Conflicts: # app/storage/schema.py
This commit is contained in:
commit
562fa3ab09
15 files changed
+924
-157
No files matched your search
+28
-1
@@ -66,7 +66,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 == 12
|
||||
assert LATEST == 13
|
||||
# A second open finds it current and applies nothing.
|
||||
assert Store(path).migrations_applied == []
|
||||
|
||||
@@ -260,6 +260,33 @@ def test_v10_backfills_posted_at_by_the_same_rule_upsert_uses(
|
||||
assert after_untrusted.posted_at == before_untrusted.posted_at == before_untrusted.first_seen
|
||||
|
||||
|
||||
def test_v13_recomputes_country_from_place_unless_the_board_or_extract_set_it(
|
||||
tmp_path: Path, clock: Clock) -> None:
|
||||
path = tmp_path / "v11.db"
|
||||
store = Store(path)
|
||||
store.clock = clock
|
||||
wrong = posting("1", place="Bogota, CO") # was read as US
|
||||
several = posting("2", place="Dublin, London") # was ''
|
||||
given = posting("3", place="Bogota, CO", country="US") # the board said so
|
||||
extracted = posting("4", place="Bogota, CO")
|
||||
for item in (wrong, several, given, extracted):
|
||||
store.upsert_role(item)
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("UPDATE roles SET country = 'US' WHERE place = 'Bogota, CO'")
|
||||
conn.execute("UPDATE roles SET country = '' WHERE uid = ?", (several.uid,))
|
||||
conn.execute("UPDATE roles SET extracted_at = '2026-09-23' WHERE uid = ?",
|
||||
(extracted.uid,))
|
||||
conn.execute("PRAGMA user_version = 12")
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == list(range(13, LATEST + 1))
|
||||
countries = {uid: role.country for uid in (wrong.uid, several.uid, given.uid, extracted.uid)
|
||||
if (role := migrated.role(uid)) is not None}
|
||||
assert countries == {wrong.uid: "CO", several.uid: "EU", given.uid: "US",
|
||||
extracted.uid: "US"}
|
||||
|
||||
|
||||
def test_state_is_a_mapping(store: Store) -> None:
|
||||
store.state["ats:last"] = "2026-09-23"
|
||||
assert store.state["ats:last"] == "2026-09-23"
|
||||
|
||||
Reference in new issue
Block a user