Spaces:
Sleeping
Sleeping
Download tests/integration/test_api_endpoints.py from neurostack-in/talk2map-test: direct link, hf CLI and curl.
- Browser
- Download file 1.62 kB
-
https://huggingface.co/spaces/neurostack-in/talk2map-test/resolve/main/tests/integration/test_api_endpoints.py
- Command line
-
hf download hf://spaces/neurostack-in/talk2map-test/tests/integration/test_api_endpoints.py
-
curl -L -o test_api_endpoints.py https://huggingface.co/spaces/neurostack-in/talk2map-test/resolve/main/tests/integration/test_api_endpoints.py
1.62 kB
| 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 | |