Initial commit: backend API, data models, and test suite

FastAPI backend for personal health and skincare data with MCP export.
Includes SQLModel models for products, inventory, medications, lab results,
routines, and skin condition snapshots. Pytest suite with 111 tests running
on SQLite in-memory (no PostgreSQL required).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Piotr Oleszczyk 2026-02-26 15:10:24 +01:00
commit 8f7d893a63
32 changed files with 6282 additions and 0 deletions

View file

@ -0,0 +1,54 @@
import uuid
def test_get_inventory_by_id(client, created_product):
pid = created_product["id"]
r = client.post(f"/products/{pid}/inventory", json={"is_opened": False})
assert r.status_code == 201
inv_id = r.json()["id"]
r2 = client.get(f"/inventory/{inv_id}")
assert r2.status_code == 200
assert r2.json()["id"] == inv_id
def test_get_inventory_not_found(client):
r = client.get(f"/inventory/{uuid.uuid4()}")
assert r.status_code == 404
def test_update_inventory_opened(client, created_product):
pid = created_product["id"]
r = client.post(f"/products/{pid}/inventory", json={"is_opened": False})
inv_id = r.json()["id"]
r2 = client.patch(
f"/inventory/{inv_id}",
json={"is_opened": True, "opened_at": "2026-01-15"},
)
assert r2.status_code == 200
data = r2.json()
assert data["is_opened"] is True
assert data["opened_at"] == "2026-01-15"
def test_update_inventory_not_found(client):
r = client.patch(f"/inventory/{uuid.uuid4()}", json={"is_opened": True})
assert r.status_code == 404
def test_delete_inventory(client, created_product):
pid = created_product["id"]
r = client.post(f"/products/{pid}/inventory", json={})
inv_id = r.json()["id"]
r2 = client.delete(f"/inventory/{inv_id}")
assert r2.status_code == 204
r3 = client.get(f"/inventory/{inv_id}")
assert r3.status_code == 404
def test_delete_inventory_not_found(client):
r = client.delete(f"/inventory/{uuid.uuid4()}")
assert r.status_code == 404