feat: Add method to get extractions by status and implement user info retrieval in extraction service
This commit is contained in:
@@ -129,3 +129,36 @@ class TestExtractionRepository:
|
||||
assert result.sound_id == TEST_SOUND_ID
|
||||
extraction_repo.session.commit.assert_called_once()
|
||||
extraction_repo.session.refresh.assert_called_once_with(extraction)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_by_status(self, extraction_repo):
|
||||
"""Test getting extractions by status."""
|
||||
mock_extractions = [
|
||||
Extraction(
|
||||
id=1,
|
||||
service="youtube",
|
||||
service_id="test123",
|
||||
url="https://www.youtube.com/watch?v=test1",
|
||||
user_id=1,
|
||||
status="processing",
|
||||
),
|
||||
Extraction(
|
||||
id=2,
|
||||
service="youtube",
|
||||
service_id="test456",
|
||||
url="https://www.youtube.com/watch?v=test2",
|
||||
user_id=1,
|
||||
status="processing",
|
||||
),
|
||||
]
|
||||
|
||||
mock_result = Mock()
|
||||
mock_result.all.return_value = mock_extractions
|
||||
|
||||
extraction_repo.session.exec = AsyncMock(return_value=mock_result)
|
||||
|
||||
result = await extraction_repo.get_by_status("processing")
|
||||
|
||||
assert len(result) == 2
|
||||
assert all(extraction.status == "processing" for extraction in result)
|
||||
extraction_repo.session.exec.assert_called_once()
|
||||
|
||||
@@ -217,6 +217,10 @@ class TestExtractionService:
|
||||
extraction_service.extraction_repo.get_by_service_and_id = AsyncMock(
|
||||
return_value=None,
|
||||
)
|
||||
# Mock user repository
|
||||
from app.models.user import User
|
||||
mock_user = User(id=1, name="Test User")
|
||||
extraction_service.user_repo.get_by_id = AsyncMock(return_value=mock_user)
|
||||
|
||||
# Mock service detection
|
||||
service_info = {
|
||||
|
||||
Reference in New Issue
Block a user