1.6 KiB
1.6 KiB
Task: Fix test watchlist fixture for sector rotation tests
Goal
Fix the watchlist fixture in tests/conftest.py so that sector rotation tests can properly create and use watchlists with user ownership.
Root Cause
The watchlist fixture in conftest.py sets user_id: "test-user-1" but the test_user fixture generates a UUID for user_id. When the rotation service calls _require_watchlist_owner, the user IDs don't match, causing 404 errors.
Requirements
Fix in src/backend/tests/conftest.py
- In the
watchlistfixture, use the same user ID astest_user:- Extract the user ID from
test_userfixture's UUID - Or use a fixed user ID like
"test-user-1"in both fixtures
- Extract the user ID from
- Ensure the fixture returns a watchlist dict with:
id: a consistent UUID (not random per test)user_id: matching the test user's IDname,description,is_default: reasonable defaults
Alternative: Fix in rotation service tests
If the fixture approach is too invasive, fix the rotation service tests to use the correct user ID when calling endpoints.
Acceptance Criteria
- The
watchlistfixture'suser_idmatches thetest_userfixture's user ID - Sector rotation tests that create watchlists pass
- No regressions in existing alert tests
Files to Modify
src/backend/tests/conftest.py
Files to Read First
src/backend/tests/conftest.py— thewatchlistandtest_userfixturessrc/backend/tests/test_sector_rotation.py— tests that depend on the fixturesrc/backend/services/rotation_service.py— how ownership is checked