Fix test isolation: redirect hits.db to tmp_path in web RBAC tests
Dashboard route queries utils.database, which was pointing at the real data/hits.db instead of a temp file, causing no such table: hits.
This commit is contained in:
@@ -18,10 +18,16 @@ def isolated_web(tmp_path, monkeypatch):
|
|||||||
db_path = tmp_path / "web.db"
|
db_path = tmp_path / "web.db"
|
||||||
cfg_path = tmp_path / "runtime_config.json"
|
cfg_path = tmp_path / "runtime_config.json"
|
||||||
|
|
||||||
|
import utils.database as hitdb_mod
|
||||||
|
|
||||||
|
hits_path = tmp_path / "hits.db"
|
||||||
|
|
||||||
monkeypatch.setattr(db_mod, "DB_FILE", db_path)
|
monkeypatch.setattr(db_mod, "DB_FILE", db_path)
|
||||||
monkeypatch.setattr(cfg_mod, "RUNTIME_CONFIG_PATH", cfg_path)
|
monkeypatch.setattr(cfg_mod, "RUNTIME_CONFIG_PATH", cfg_path)
|
||||||
|
monkeypatch.setattr(hitdb_mod, "DB_FILE", hits_path)
|
||||||
|
|
||||||
db_mod.init_db()
|
db_mod.init_db()
|
||||||
|
hitdb_mod.init_db()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
Reference in New Issue
Block a user