15 lines
699 B
Python
15 lines
699 B
Python
import sqlite3
|
|
from sfm.database import SeismoDb
|
|
def _cols(db):
|
|
with sqlite3.connect(db.db_path) as c:
|
|
return {r[1] for r in c.execute("PRAGMA table_info(events)")}
|
|
def test_fresh_db_has_reviewed_real(tmp_path):
|
|
assert "reviewed_real" in _cols(SeismoDb(tmp_path/"s.db"))
|
|
def test_existing_db_migrates_reviewed_real(tmp_path):
|
|
p = tmp_path/"s.db"; db = SeismoDb(p)
|
|
with sqlite3.connect(p) as c:
|
|
c.execute("ALTER TABLE events DROP COLUMN reviewed_real")
|
|
assert "reviewed_real" not in _cols(db) # dropped (read via existing handle/connection)
|
|
SeismoDb(p) # re-open migrates
|
|
assert "reviewed_real" in _cols(SeismoDb(p))
|