sync
This commit is contained in:
@@ -57,6 +57,37 @@ def test_invalid_period_is_rejected() -> None:
|
||||
assert client.get("/api/v1/activity?sort=unknown").status_code == 422
|
||||
|
||||
|
||||
def test_timeline_includes_more_than_catch_page_and_sitemap_includes_old_spots() -> None:
|
||||
with Session(engine) as db:
|
||||
fish = db.scalar(select(Fish).where(Fish.slug == "pike"))
|
||||
water = db.scalar(select(Waterbody).where(Waterbody.slug == "test-lake"))
|
||||
spot = Spot(waterbody=water, x=901, y=902)
|
||||
db.add(spot)
|
||||
db.flush()
|
||||
spot_id = spot.id
|
||||
reports = [CatchReport(fish=fish, waterbody=water, spot=spot, weight_g=1000,
|
||||
reported_at=datetime.now(timezone.utc) - timedelta(hours=1 if i < 60 else 100),
|
||||
source_type=SourceType.manual_import, source_confidence=70,
|
||||
moderation_status=ModerationStatus.approved) for i in range(61)]
|
||||
db.add_all(reports)
|
||||
db.commit()
|
||||
try:
|
||||
result = client.get(f"/api/v1/spots/{spot_id}/timeline")
|
||||
assert result.status_code == 200
|
||||
assert sum(row["count"] for row in result.json()) == 60
|
||||
assert len(client.get(f"/api/v1/spots/{spot_id}/catches").json()) == 50
|
||||
for report in reports:
|
||||
report.reported_at = datetime.now(timezone.utc) - timedelta(days=10)
|
||||
db.commit()
|
||||
assert "/spots/test-lake-901x902" in client.get("/api/v1/public-spot-pages").json()
|
||||
finally:
|
||||
for report in reports:
|
||||
db.delete(report)
|
||||
db.flush()
|
||||
db.delete(spot)
|
||||
db.commit()
|
||||
|
||||
|
||||
def test_list_pagination_and_filter_validation() -> None:
|
||||
assert client.get("/api/v1/fishes?limit=0").status_code == 422
|
||||
assert client.get("/api/v1/fishes?limit=1&offset=0").status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user