fix: disable rate limiting in tests by mocking Limiter
This commit is contained in:
@@ -147,11 +147,14 @@ def test_app(mock_config, temp_auth_file, temp_rbac_file, mock_docker_client):
|
|||||||
"""Create FastAPI test client with mocked dependencies."""
|
"""Create FastAPI test client with mocked dependencies."""
|
||||||
# Patch Docker client before importing main
|
# Patch Docker client before importing main
|
||||||
with patch("docker.DockerClient", return_value=mock_docker_client):
|
with patch("docker.DockerClient", return_value=mock_docker_client):
|
||||||
from main import app
|
# Mock the limiter to disable rate limiting during tests
|
||||||
# Disable rate limiting during tests to avoid 429 errors
|
mock_limiter = Mock()
|
||||||
app.state.limiter.enabled = False
|
mock_limiter.limit = lambda *args, **kwargs: lambda func: func
|
||||||
client = TestClient(app)
|
|
||||||
yield client
|
with patch("slowapi.Limiter", return_value=mock_limiter):
|
||||||
|
from main import app
|
||||||
|
client = TestClient(app)
|
||||||
|
yield client
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
Reference in New Issue
Block a user