from app.knowledge import KnowledgeBase
from app.schemas import TravelPreferences


def make_preferences(extra_requirements: str = "") -> TravelPreferences:
    return TravelPreferences(
        themes=["亲子"],
        duration="half_day",
        pace="relaxed",
        interests=["自然风光"],
        adults=2,
        children=1,
        child_ages=[3],
        transport="public_transport",
        budget_level="standard",
        extra_requirements=extra_requirements,
    )


def test_retrieval_is_deterministic():
    knowledge = KnowledgeBase()
    first = [place["id"] for place in knowledge.retrieve(make_preferences())]
    second = [place["id"] for place in knowledge.retrieve(make_preferences())]
    assert first == second


def test_avoid_climbing_excludes_high_intensity_places():
    knowledge = KnowledgeBase()
    result = knowledge.retrieve(make_preferences("带婴儿车，不爬山"))
    assert all(place["intensity"] != "high" for place in result)

