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.

33 lines
1.3 KiB
Python

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# backend/tests/test_api_trip.py
def test_upcoming(client):
u = client.get("/api/trip/upcoming").json()
assert u["route"]["out"]["mode"] == "KTX 101" and u["route"]["back"]["mode"] == "KTX 158"
assert u["expense"]["budget"] == 400000 and u["expense"]["planned"] == 331600
assert len(u["check"]) == 3 # 서류·결제 / 발표 / 짐
d1 = next(d for d in u["days"] if d["id"] == "d1")
hot = [it for it in d1["items"] if it.get("hot")]
assert hot and hot[0]["title"] == "분기 리포트 발표"
assert u["trip"]["dday"] == "D-4"
def test_saved_list(client):
rows = client.get("/api/trip/saved").json()
assert len(rows) == 3
sv1 = next(r for r in rows if r["id"] == "sv1")
assert sv1["spark"] == [120, 118, 112, 108, 104, 98, 89]
assert sv1["down"] is True and sv1["delta"] == "−12%"
def test_toggle_watch(client):
before = next(r for r in client.get("/api/trip/saved").json() if r["id"] == "sv3")
assert before["watch"] is False
r = client.post("/api/trip/saved/sv3/watch", json={}).json()
assert r["watch"] is True
# 영속 확인
after = next(r for r in client.get("/api/trip/saved").json() if r["id"] == "sv3")
assert after["watch"] is True
def test_watch_404(client):
assert client.post("/api/trip/saved/nope/watch", json={}).status_code == 404