# backend/tests/test_seed_research_trip.py
from sqlmodel import select

from app.models import (
    RagChunk,
    ResearchChart,
    ResearchCollection,
    ResearchQA,
    ResearchReport,
    ResearchSource,
    SavedTrip,
    Trip,
    TripChecklist,
    TripDay,
    TripPlan,
    TripPrep,
    TripRoute,
)


def test_research_seed_counts(client, session):
    s, _ = session
    assert len(s.exec(select(ResearchCollection)).all()) == 3
    srcs = s.exec(select(ResearchSource)).all()
    assert len(srcs) == 5 and sum(1 for x in srcs if x.learned) == 4
    assert len(s.exec(select(ResearchReport)).all()) == 1
    assert len(s.exec(select(ResearchQA)).all()) == 1
    assert len(s.exec(select(ResearchChart)).all()) == 1
    assert len(s.exec(select(RagChunk)).all()) >= 5  # 소스마다 1청크 이상


def test_trip_seed_counts(client, session):
    s, _ = session
    assert len(s.exec(select(Trip)).all()) == 1
    assert len(s.exec(select(TripRoute)).all()) == 2
    preps = s.exec(select(TripPrep)).all()
    assert len(preps) == 5 and sum(1 for p in preps if p.state == "doing") == 1
    assert len(s.exec(select(TripDay)).all()) == 2
    assert len(s.exec(select(TripChecklist)).all()) == 7
    assert len(s.exec(select(SavedTrip)).all()) == 3
    assert len(s.exec(select(TripPlan)).all()) == 2
