Skip to content

Commit f1f4d20

Browse files
committed
fix: patch redis_client in test classes to match new Redis guards
The redis_client None guards added in the previous commit caused 9 test failures because redis_client is None in the test environment. Fix: added @patch('routes.playground.indexing.redis_client', MagicMock()) to TestIndexEndpoint, TestSessionConflict, and TestStatusEndpoint. TestStatusEndpoint uses MagicMock(get=MagicMock(return_value=None)) so test_job_not_found_returns_404 exercises the real AnonymousIndexingJob code path (redis.get returns None -> job not found -> 404). 289 tests pass locally. Verified before committing.
1 parent c36e272 commit f1f4d20

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

backend/tests/test_anonymous_indexing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def test_job_stats_to_dict(self):
262262

263263
# ENDPOINT TESTS (Integration)
264264

265+
@patch('routes.playground.indexing.redis_client', MagicMock())
265266
class TestIndexEndpoint:
266267
"""Integration tests for POST /playground/index."""
267268

@@ -420,6 +421,7 @@ def test_github_rate_limit_returns_429(self, mock_metadata, client):
420421

421422
# SESSION CONFLICT TESTS
422423

424+
@patch('routes.playground.indexing.redis_client', MagicMock())
423425
class TestSessionConflict:
424426
"""Tests for session-already-has-repo behavior."""
425427

@@ -504,6 +506,7 @@ def test_expired_repo_allows_new_indexing(
504506

505507
# STATUS ENDPOINT TESTS (GET /playground/index/{job_id})
506508

509+
@patch('routes.playground.indexing.redis_client', MagicMock(get=MagicMock(return_value=None)))
507510
class TestStatusEndpoint:
508511
"""Tests for GET /playground/index/{job_id} status endpoint."""
509512

0 commit comments

Comments
 (0)