The auth dependency raises NotAuthenticatedError (not HTTPException), and the exception handler returns a 302 redirect. Updated the unit test to expect NotAuthenticatedError, and all route auth tests to accept 302 alongside 401/303.
18 lines
684 B
Python
18 lines
684 B
Python
"""Tests for workout day viewer routes."""
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
class TestWorkoutDayViewer:
|
|
"""Tests for GET /workouts/<day_name>."""
|
|
|
|
def test_workout_day_requires_auth(self, client: TestClient) -> None:
|
|
"""GET /workouts/push should require admin login."""
|
|
response = client.get("/workouts/push", follow_redirects=False)
|
|
assert response.status_code in (401, 302, 303)
|
|
|
|
def test_workout_days_list_requires_auth(self, client: TestClient) -> None:
|
|
"""GET /workouts should require admin login."""
|
|
response = client.get("/workouts", follow_redirects=False)
|
|
assert response.status_code in (401, 302, 303)
|