mirror of
https://github.com/sstent/FitTrack_GarminSync.git
synced 2026-01-26 09:01:53 +00:00
feat: Implement single sync job management and progress tracking
This commit is contained in:
@@ -18,6 +18,7 @@ async def test_rate_limiter_allows_requests_within_limit():
|
||||
except HTTPException:
|
||||
pytest.fail("HTTPException raised unexpectedly.")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_rate_limiter_raises_exception_when_exceeded():
|
||||
"""Test that the rate limiter raises an HTTPException when the rate limit is exceeded."""
|
||||
@@ -25,15 +26,20 @@ async def test_rate_limiter_raises_exception_when_exceeded():
|
||||
mock_request = MagicMock()
|
||||
|
||||
# Mock the limiter.test method
|
||||
with patch.object(rate_limiter.limiter, 'test') as mock_limiter_test:
|
||||
mock_limiter_test.side_effect = [True, False] # First call returns True, second returns False
|
||||
with patch.object(rate_limiter.limiter, "test") as mock_limiter_test:
|
||||
mock_limiter_test.side_effect = [
|
||||
True,
|
||||
False,
|
||||
] # First call returns True, second returns False
|
||||
|
||||
await rate_limiter(mock_request) # First call, should pass
|
||||
await rate_limiter(mock_request) # First call, should pass
|
||||
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
await rate_limiter(mock_request) # Second call, should fail
|
||||
await rate_limiter(mock_request) # Second call, should fail
|
||||
|
||||
assert exc_info.value.status_code == 429
|
||||
mock_limiter_test.assert_called_with(rate_limiter.rate_limit_item, "single_user_system")
|
||||
mock_limiter_test.assert_called_with(
|
||||
rate_limiter.rate_limit_item, "single_user_system"
|
||||
)
|
||||
|
||||
assert exc_info.value.status_code == 429
|
||||
|
||||
Reference in New Issue
Block a user