"""Tests for profile management routes.""" from fastapi.testclient import TestClient from tests.conftest import set_profile_cookie class TestProfileSwitcher: """Tests for POST /profiles/switch.""" def test_switch_profile_redirects_to_workouts(self, client: TestClient) -> None: """POST /profiles/switch should set cookie and redirect to /workouts.""" response = client.post( "/profiles/switch", data={"profile_id": "1"}, follow_redirects=False, ) assert response.status_code == 303 assert response.headers["location"] == "/workouts" class TestProfileList: """Tests for GET /profiles.""" def test_profiles_page_requires_profile(self, client: TestClient) -> None: """GET /profiles should redirect to / without profile cookie.""" response = client.get("/profiles", follow_redirects=False) assert response.status_code == 302 assert response.headers["location"] == "/" def test_profiles_page_with_profile(self, client: TestClient) -> None: """GET /profiles should succeed with a valid profile cookie.""" set_profile_cookie(client, 1) response = client.get("/profiles") assert response.status_code == 200