refactor: make mock_enqueue_job fixture opt-in instead of autouse

Tests that call POST /api/counter/increment now explicitly request
the mock_enqueue_job fixture. This prevents the mock from masking
issues in other tests that don't need it.
This commit is contained in:
counterweight 2025-12-21 23:29:48 +01:00
parent 6f3e729b25
commit 4d9edd7fd4
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 10 additions and 8 deletions

View file

@ -241,13 +241,15 @@ async def user_no_roles(client_factory):
}
@pytest.fixture(autouse=True)
@pytest.fixture
def mock_enqueue_job():
"""Mock job enqueueing for all tests.
"""Mock job enqueueing for tests that hit the counter increment endpoint.
pgqueuer requires PostgreSQL-specific features that aren't available
in the test database setup. We mock the enqueue function to avoid
connection issues while still testing the counter logic.
Tests that call POST /api/counter/increment must use this fixture.
"""
mock = AsyncMock(return_value=1) # Return a fake job ID
with patch("routes.counter.enqueue_random_number_job", mock):