Add startup scheme

This commit is contained in:
Rene Arumetsa
2026-07-26 21:36:26 +03:00
parent c40c871a4b
commit 94fe57a596
5 changed files with 42 additions and 1 deletions

View File

@@ -73,6 +73,11 @@ class FakePocketBase:
async def count_records(self) -> int:
return len(self.records)
async def get_collection_fields(self) -> set[str]:
if self.schema_fields is None:
return set(economy._default_user()) | {"user_id"}
return set(self.schema_fields)
# -- test helpers -------------------------------------------------------
def record_for(self, user_id: int) -> dict:
for record in self.records.values():
@@ -83,7 +88,7 @@ class FakePocketBase:
def _install(monkeypatch, fake: FakePocketBase) -> FakePocketBase:
for name in ("get_record", "create_record", "update_record",
"list_all_records", "count_records"):
"list_all_records", "count_records", "get_collection_fields"):
monkeypatch.setattr(pb_client, name, getattr(fake, name))
monkeypatch.setattr(economy, "HOUSE_ID", None)
monkeypatch.setattr(economy, "_house_pb_id", None)

View File

@@ -100,6 +100,12 @@ class TestClaim:
class TestSchemaDetection:
def test_missing_fields_reported(self, fake_pb_without_quest_fields):
assert run(economy.missing_schema_fields()) == ["quest_daily", "quest_weekly"]
def test_healthy_schema_reports_nothing(self, fake_pb):
assert run(economy.missing_schema_fields()) == []
def test_missing_quest_fields_warn_and_zero_progress(
self, fake_pb_without_quest_fields, caplog
):