feat: Implement background extraction processor with concurrency control
- Added `ExtractionProcessor` class to handle extraction queue processing in the background. - Implemented methods for starting, stopping, and queuing extractions with concurrency limits. - Integrated logging for monitoring the processor's status and actions. - Created tests for the extraction processor to ensure functionality and error handling. test: Add unit tests for extraction API endpoints - Created tests for successful extraction creation, authentication checks, and processor status retrieval. - Ensured proper responses for authenticated and unauthenticated requests. test: Implement unit tests for extraction repository - Added tests for creating, retrieving, and updating extractions in the repository. - Mocked database interactions to validate repository behavior without actual database access. test: Add comprehensive tests for extraction service - Developed tests for extraction creation, service detection, and sound record creation. - Included tests for handling duplicate extractions and invalid URLs. test: Add unit tests for extraction background processor - Created tests for the `ExtractionProcessor` class to validate its behavior under various conditions. - Ensured proper handling of extraction queuing, processing, and completion callbacks. fix: Update OAuth service tests to use AsyncMock - Modified OAuth provider tests to use `AsyncMock` for mocking asynchronous HTTP requests.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""Tests for OAuth service."""
|
||||
|
||||
from typing import Any
|
||||
from unittest.mock import Mock, patch
|
||||
from unittest.mock import AsyncMock, Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -117,7 +117,7 @@ class TestGoogleOAuthProvider:
|
||||
"picture": "https://example.com/avatar.jpg",
|
||||
}
|
||||
|
||||
with patch("httpx.AsyncClient.get") as mock_get:
|
||||
with patch("httpx.AsyncClient.get", new_callable=AsyncMock) as mock_get:
|
||||
mock_response = Mock()
|
||||
mock_response.status_code = 200
|
||||
mock_response.json.return_value = mock_response_data
|
||||
@@ -162,7 +162,7 @@ class TestGitHubOAuthProvider:
|
||||
{"email": "secondary@example.com", "primary": False, "verified": True},
|
||||
]
|
||||
|
||||
with patch("httpx.AsyncClient.get") as mock_get:
|
||||
with patch("httpx.AsyncClient.get", new_callable=AsyncMock) as mock_get:
|
||||
# Mock user profile response
|
||||
mock_user_response = Mock()
|
||||
mock_user_response.status_code = 200
|
||||
@@ -174,7 +174,7 @@ class TestGitHubOAuthProvider:
|
||||
mock_emails_response.json.return_value = mock_emails_data
|
||||
|
||||
# Return different responses based on URL
|
||||
def side_effect(url, **kwargs):
|
||||
async def side_effect(url, **kwargs):
|
||||
if "user/emails" in str(url):
|
||||
return mock_emails_response
|
||||
return mock_user_response
|
||||
|
||||
Reference in New Issue
Block a user