feat: audit full alpha catalog
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user