from fastapi.testclient import TestClient from api.app import app client = TestClient(app) # Shared bounding box payload for all chat requests BBOX = { "north_east": {"lat": 40.0, "lon": -73.0}, "south_west": {"lat": 39.0, "lon": -74.0}, } def test_health_check(): r = client.get("/health") assert r.status_code == 200 assert r.json()["status"] == "ok" def test_chat_with_empty_body(): r = client.post("/chat", json={ "user_input": "", "conversation_history": [], "bounding_box": BBOX, }) assert r.status_code == 200 data = r.json() assert "agent_reply" in data def test_chat_with_text_only(): r = client.post("/chat", json={ "user_input": "Find cafes", "conversation_history": [], "bounding_box": BBOX, }) assert r.status_code == 200 data = r.json() assert "agent_reply" in data def test_chat_with_bbox_and_text(): r = client.post("/chat", json={ "user_input": "parks", "conversation_history": [], "bounding_box": BBOX, }) assert r.status_code == 200 data = r.json() assert "agent_reply" in data def test_chat_with_conversation_history(): history = [ {"human": "hello", "ai": {"message": "Hi there!"}}, {"human": "find restaurants", "ai": {"message": "Here are some places."}}, ] r = client.post("/chat", json={ "user_input": "any cafes?", "conversation_history": history, "bounding_box": BBOX, }) assert r.status_code == 200 data = r.json() assert len(data["conversation_history"]) >= 3