first prototype commit

This commit is contained in:
2026-08-09 21:45:06 -04:00
commit 40613a00d5
36 changed files with 4371 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import pytest
from fastapi.testclient import TestClient
from backend.main import app
def test_root_endpoint():
with TestClient(app) as client:
response = client.get("/")
assert response.status_code == 200
assert response.json()["status"] == "running"
def test_demo_login():
with TestClient(app) as client:
response = client.post("/api/auth/demo-login", json={"email": "admin@choreus.app"})
assert response.status_code == 200
data = response.json()
assert "access_token" in data
assert data["user"]["email"] == "admin@choreus.app"
assert data["user"]["role"] == "admin"
def test_google_auth_mock():
with TestClient(app) as client:
response = client.post("/api/auth/google", json={
"credential": "mock_token",
"email": "newuser@choreus.app",
"name": "New User",
"avatar_url": "https://api.dicebear.com/7.x/bottts/svg?seed=NewUser"
})
assert response.status_code == 200
data = response.json()
assert data["user"]["email"] == "newuser@choreus.app"
assert data["user"]["role"] == "regular"
+47
View File
@@ -0,0 +1,47 @@
import pytest
from fastapi.testclient import TestClient
from backend.main import app
def test_list_chores():
with TestClient(app) as client:
auth_res = client.post("/api/auth/demo-login", json={"email": "admin@choreus.app"})
token = auth_res.json()["access_token"]
headers = {"Authorization": f"Bearer {token}"}
response = client.get("/api/chores/types", headers=headers)
assert response.status_code == 200
chores = response.json()
assert len(chores) >= 1
assert "title" in chores[0]
def test_create_and_complete_chore():
with TestClient(app) as client:
admin_res = client.post("/api/auth/demo-login", json={"email": "admin@choreus.app"})
admin_token = admin_res.json()["access_token"]
admin_headers = {"Authorization": f"Bearer {admin_token}"}
# Create chore
chore_res = client.post("/api/chores/types", headers=admin_headers, json={
"title": "Clean Garage",
"description": "Organize tools and sweep floor",
"star_reward": 5,
"recurrence": "weekly",
"icon": "Wrench"
})
assert chore_res.status_code == 200
chore_data = chore_res.json()
chore_id = chore_data["id"]
# Complete chore as user
user_res = client.post("/api/auth/demo-login", json={"email": "leo@choreus.app"})
user_token = user_res.json()["access_token"]
user_headers = {"Authorization": f"Bearer {user_token}"}
comp_res = client.post("/api/chores/complete", headers=user_headers, json={
"chore_type_id": chore_id,
"notes": "Done with garage!"
})
assert comp_res.status_code == 200
comp_data = comp_res.json()
assert comp_data["stars_earned"] == 5
assert comp_data["chore_title"] == "Clean Garage"