Refactor test files for improved readability and consistency

- Removed unnecessary blank lines and adjusted formatting in test files.
- Ensured consistent use of commas in function calls and assertions across various test cases.
- Updated import statements for better organization and clarity.
- Enhanced mock setups in tests for better isolation and reliability.
- Improved assertions to follow a consistent style for better readability.
This commit is contained in:
JSC
2025-07-31 21:37:04 +02:00
parent e69098d633
commit 8847131f24
42 changed files with 602 additions and 616 deletions

View File

@@ -1,6 +1,5 @@
"""Tests for extraction background processor."""
import asyncio
from unittest.mock import AsyncMock, Mock, patch
import pytest
@@ -30,7 +29,7 @@ class TestExtractionProcessor:
"""Test starting and stopping the processor."""
# Mock the _process_queue method to avoid actual processing
with patch.object(
processor, "_process_queue", new_callable=AsyncMock
processor, "_process_queue", new_callable=AsyncMock,
) as mock_process:
# Start the processor
await processor.start()
@@ -138,12 +137,12 @@ class TestExtractionProcessor:
# Mock the extraction service
mock_service = Mock()
mock_service.process_extraction = AsyncMock(
return_value={"status": "completed", "id": extraction_id}
return_value={"status": "completed", "id": extraction_id},
)
with (
patch(
"app.services.extraction_processor.AsyncSession"
"app.services.extraction_processor.AsyncSession",
) as mock_session_class,
patch(
"app.services.extraction_processor.ExtractionService",
@@ -168,7 +167,7 @@ class TestExtractionProcessor:
with (
patch(
"app.services.extraction_processor.AsyncSession"
"app.services.extraction_processor.AsyncSession",
) as mock_session_class,
patch(
"app.services.extraction_processor.ExtractionService",
@@ -193,12 +192,12 @@ class TestExtractionProcessor:
# Mock extraction service
mock_service = Mock()
mock_service.get_pending_extractions = AsyncMock(
return_value=[{"id": 100, "status": "pending"}]
return_value=[{"id": 100, "status": "pending"}],
)
with (
patch(
"app.services.extraction_processor.AsyncSession"
"app.services.extraction_processor.AsyncSession",
) as mock_session_class,
patch(
"app.services.extraction_processor.ExtractionService",
@@ -222,15 +221,15 @@ class TestExtractionProcessor:
return_value=[
{"id": 100, "status": "pending"},
{"id": 101, "status": "pending"},
]
],
)
with (
patch(
"app.services.extraction_processor.AsyncSession"
"app.services.extraction_processor.AsyncSession",
) as mock_session_class,
patch.object(
processor, "_process_single_extraction", new_callable=AsyncMock
processor, "_process_single_extraction", new_callable=AsyncMock,
) as mock_process,
patch(
"app.services.extraction_processor.ExtractionService",
@@ -267,15 +266,15 @@ class TestExtractionProcessor:
{"id": 100, "status": "pending"},
{"id": 101, "status": "pending"},
{"id": 102, "status": "pending"},
]
],
)
with (
patch(
"app.services.extraction_processor.AsyncSession"
"app.services.extraction_processor.AsyncSession",
) as mock_session_class,
patch.object(
processor, "_process_single_extraction", new_callable=AsyncMock
processor, "_process_single_extraction", new_callable=AsyncMock,
) as mock_process,
patch(
"app.services.extraction_processor.ExtractionService",