You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.6 KiB
Python

# backend/tests/test_api_life.py
def test_overview_shape(client):
r = client.get("/api/life/overview").json()
assert set(r["sources"]) == {"health", "finance", "knowledge"}
assert r["finance"]["budget"]["spent"] == 1284000
assert r["knowledge"]["stats"]["items"] == 1248
assert r["health"]["sleep"]["week"] == [72, 65, 88, 60, 90, 78, 86]
def test_habit_tick_increments(client):
before = next(h for h in client.get("/api/life/health").json()["habits"] if h["id"] == "water")
assert before["done"] == 5
after = client.post("/api/life/habits/water/tick").json()["habit"]
assert after["done"] == 6
def test_habit_tick_caps_at_total(client):
r = client.post("/api/life/habits/vitamin/tick").json()["habit"]
assert r["done"] == 1 # 1/1 유지
def test_knowledge_search_filter(client):
r = client.get("/api/life/knowledge", params={"q": "리텐션"}).json()
titles = [it["title"] for it in r["items"]]
assert "분기 회고 — 리텐션 실험 메모" in titles
def test_knowledge_search_empty(client):
r = client.get("/api/life/knowledge", params={"q": "존재하지않는검색어zzz"}).json()
assert r["items"] == []
def test_knowledge_ask_fallback(client):
r = client.post("/api/life/knowledge/ask", json={"q": "AI 에이전트 설계 요약"}).json()
assert "오케스트레이터-워커" in r["body"]
assert len(r["sources"]) == 3
def test_finance_subs_soon(client):
fin = client.get("/api/life/finance").json()
netflix = next(x for x in fin["subs"] if x["id"] == "sub-netflix")
assert netflix["in_days"] == 2 and netflix["paused"] is False