3f2c765c84
- POST/GET/PUT/DELETE /api/foods per spec 3.1 (minus restore) - Service layer (services/foods.py) with shared soft-delete query helper - FoodCreate extended, FoodUpdate/FoodRead schemas added - Barcode conflict returns 409; deleted foods hidden from search, visible by id and via include_deleted=true - 29 new tests, full suite green (36 passed)
26 lines
728 B
Python
26 lines
728 B
Python
"""Example API tests — scaffold for future suites (spec §8.4)."""
|
|
|
|
|
|
def test_health(client):
|
|
resp = client.get("/api/health")
|
|
assert resp.status_code == 200
|
|
assert resp.json() == {"status": "ok"}
|
|
|
|
|
|
def test_list_foods_returns_list(client):
|
|
"""GET /api/foods returns a list (may contain data from other tests)."""
|
|
resp = client.get("/api/foods")
|
|
assert resp.status_code == 200
|
|
assert isinstance(resp.json(), list)
|
|
|
|
|
|
def test_get_log_empty(client):
|
|
resp = client.get("/api/log", params={"date": "2026-07-25"})
|
|
assert resp.status_code == 200
|
|
assert resp.json() == []
|
|
|
|
|
|
def test_current_target_none(client):
|
|
resp = client.get("/api/targets/current")
|
|
assert resp.status_code == 404
|