Initial commit: habit tracker PWA with Google OAuth, push notifications
FastAPI + SQLAlchemy/Alembic + MariaDB backend with Jinja2/htmx/Alpine server-rendered frontend. Multi-user via Google OAuth, daily habit tracking, monthly/weekly history views, Web Push reminders via APScheduler, and PWA support (manifest, service worker, offline caching). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
from app.models.habit import ALL_WEEKDAYS_MASK, HabitType
|
||||
from app.schemas.habit import HabitCreate
|
||||
from app.services import habit_service
|
||||
|
||||
|
||||
def _make_habit(db_session, user_id, name="아침 운동"):
|
||||
data = HabitCreate(name=name, habit_type=HabitType.BUILD, weekdays_mask=ALL_WEEKDAYS_MASK)
|
||||
return habit_service.create_habit(db_session, user_id, data)
|
||||
|
||||
|
||||
def test_today_page_redirects_to_login_when_not_authenticated(client):
|
||||
response = client.get("/today", follow_redirects=False)
|
||||
assert response.status_code == 303
|
||||
assert response.headers["location"] == "/login"
|
||||
|
||||
|
||||
def test_today_page_shows_created_habit(auth_client, db_session, test_user):
|
||||
_make_habit(db_session, test_user.id, name="아침 운동")
|
||||
|
||||
response = auth_client.get("/today")
|
||||
assert response.status_code == 200
|
||||
assert "아침 운동" in response.text
|
||||
|
||||
|
||||
def test_toggle_today_page_updates_checked_state(auth_client, db_session, test_user):
|
||||
habit = _make_habit(db_session, test_user.id, name="아침 운동")
|
||||
|
||||
response = auth_client.post(f"/today/{habit.id}/toggle")
|
||||
assert response.status_code == 200
|
||||
|
||||
# 서버가 실제로 로그를 남겼는지 today API로 재확인
|
||||
today_items = auth_client.get("/api/today").json()
|
||||
assert today_items[0]["checked"] is True
|
||||
|
||||
|
||||
def test_toggle_today_page_for_other_users_habit_returns_404(auth_client, db_session, other_user):
|
||||
others_habit = _make_habit(db_session, other_user.id, name="남의 습관")
|
||||
|
||||
response = auth_client.post(f"/today/{others_habit.id}/toggle")
|
||||
assert response.status_code == 404
|
||||
Reference in New Issue
Block a user