Spaces:
Sleeping
Sleeping
File size: 1,153 Bytes
a13f875 eddd90b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | """Route tests for space/server.py (offline; mock mode)."""
import os
import sys
_HERE = os.path.dirname(os.path.abspath(__file__))
_SPACE_DIR = os.path.dirname(_HERE)
if _SPACE_DIR not in sys.path:
sys.path.insert(0, _SPACE_DIR)
def test_api_locale_mock(monkeypatch):
monkeypatch.setenv("NIGHTWAVE_MOCK", "1")
from fastapi.testclient import TestClient
import server
client = TestClient(server.create_api())
r = client.post("/api/locale", json={"lat": 30.27, "lon": -97.74})
assert r.status_code == 200
body = r.json()
assert body["resolved"] is True and body["city"]
def test_api_locale_bad_body_still_safe(monkeypatch):
monkeypatch.setenv("NIGHTWAVE_MOCK", "1")
from fastapi.testclient import TestClient
import server
client = TestClient(server.create_api())
r = client.post("/api/locale", json={"lat": "not-a-number", "lon": 0})
assert r.status_code == 422 # pydantic rejects; never 500s
def test_fallback_payload_has_memory_keys():
import server
p = server._fallback_payload("", include_caller=True)
assert p["memory_patch"] is None and p["queue_dedication"] is False
|