feat: preserve gear components through catch imports
CI / backend-and-migrations (push) Waiting to run
CI / astro-build (push) Waiting to run
CI / dependency-audit (push) Waiting to run
CI / compose-e2e (push) Waiting to run

This commit is contained in:
ik
2026-09-20 18:10:41 +07:00
parent 4e9895fbf4
commit 4f0c2d23de
15 changed files with 379 additions and 7 deletions
@@ -0,0 +1,31 @@
from datetime import datetime, timezone
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from app.database import Base
from app.models import CatchReport, CatchTackleComponent, Fish, ModerationStatus, SourceType, Waterbody
def test_catch_keeps_ordered_unresolved_gear_evidence() -> None:
engine = create_engine("sqlite:///:memory:")
Base.metadata.create_all(engine)
with Session(engine) as session:
fish = Fish(slug="pike", name_ru="Щука")
waterbody = Waterbody(slug="lake", name_ru="Озеро")
report = CatchReport(
fish=fish, waterbody=waterbody, weight_g=1000,
reported_at=datetime(2026, 9, 20, tzinfo=timezone.utc), source_type=SourceType.manual_import,
source_confidence=50, moderation_status=ModerationStatus.pending,
)
report.tackle_components.extend([
CatchTackleComponent(role="lure", position=0, raw_value="Spiker #2"),
CatchTackleComponent(role="rig", position=1, raw_value="Method Popup"),
])
session.add(report)
session.commit()
saved = session.get(CatchReport, report.id)
assert saved is not None
assert [(row.position, row.role, row.raw_value) for row in saved.tackle_components] == [
(0, "lure", "Spiker #2"), (1, "rig", "Method Popup"),
]