feat: audit full alpha catalog
CI / backend-and-migrations (push) Canceled after 0s
CI / astro-build (push) Canceled after 0s
CI / compose-e2e (push) Canceled after 0s

This commit is contained in:
ik
2026-09-07 09:37:01 +07:00
parent 600abd81f5
commit c4d1c8b87b
6 changed files with 61 additions and 6 deletions
+26
View File
@@ -0,0 +1,26 @@
from datetime import datetime, timezone
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from app.catalog_audit import audit_catalog
from app.database import Base
from app.models import CatchReport, Fish, ModerationStatus, SourceType, Spot, Waterbody
def test_catalog_audit_checks_the_whole_catalog() -> None:
engine = create_engine("sqlite://")
Base.metadata.create_all(engine)
with Session(engine) as db:
fish = Fish(slug="pike", name_ru="Щука", trophy_weight_g=10_000)
water = Waterbody(slug="lake", name_ru="Озеро", unlock_level=1)
spot = Spot(waterbody=water, x=10, y=20)
db.add(CatchReport(fish=fish, waterbody=water, spot=spot, weight_g=1000, reported_at=datetime.now(timezone.utc), source_type=SourceType.user, source_confidence=60, moderation_status=ModerationStatus.approved))
db.commit()
assert audit_catalog(db)["failures"] == 0
spot.x = 10_001
db.commit()
result = audit_catalog(db)
assert result["reports"] == 1
assert result["invalid_coordinates"] == 1
assert result["failures"] == 1