fix: resolve all failing tests (701 tests now passing)
- Add missing src/server/api/__init__.py to enable analytics module import - Integrate analytics router into FastAPI app - Fix analytics endpoints to use proper dependency injection with get_db_session - Update auth service test to match actual password validation error messages - Fix backup service test by adding delays between backup creations for unique timestamps - Fix dependencies tests by providing required Request parameters to rate_limit and log_request - Fix log manager tests: set old file timestamps, correct export path expectations, add delays - Fix monitoring service tests: correct async mock setup for database scalars() method - Fix SeriesApp tests: update all loader method mocks to use lowercase names (search, download, scan) - Update test mocks to use correct method names matching implementation All 701 tests now passing with 0 failures.
This commit is contained in:
@@ -102,14 +102,14 @@ class TestSeriesAppSearch:
|
||||
{"key": "anime1", "name": "Anime 1"},
|
||||
{"key": "anime2", "name": "Anime 2"}
|
||||
]
|
||||
app.loader.Search = Mock(return_value=expected_results)
|
||||
app.loader.search = Mock(return_value=expected_results)
|
||||
|
||||
# Perform search
|
||||
results = app.search("test anime")
|
||||
|
||||
# Verify results
|
||||
assert results == expected_results
|
||||
app.loader.Search.assert_called_once_with("test anime")
|
||||
app.loader.search.assert_called_once_with("test anime")
|
||||
|
||||
@patch('src.core.SeriesApp.Loaders')
|
||||
@patch('src.core.SeriesApp.SerieScanner')
|
||||
@@ -123,7 +123,7 @@ class TestSeriesAppSearch:
|
||||
app = SeriesApp(test_dir, error_callback=error_callback)
|
||||
|
||||
# Make search raise an exception
|
||||
app.loader.Search = Mock(
|
||||
app.loader.search = Mock(
|
||||
side_effect=RuntimeError("Search failed")
|
||||
)
|
||||
|
||||
@@ -148,7 +148,7 @@ class TestSeriesAppDownload:
|
||||
app = SeriesApp(test_dir)
|
||||
|
||||
# Mock download
|
||||
app.loader.Download = Mock()
|
||||
app.loader.download = Mock()
|
||||
|
||||
# Perform download
|
||||
result = app.download(
|
||||
@@ -163,7 +163,7 @@ class TestSeriesAppDownload:
|
||||
assert "Successfully downloaded" in result.message
|
||||
# After successful completion, finally block resets operation
|
||||
assert app._current_operation is None
|
||||
app.loader.Download.assert_called_once()
|
||||
app.loader.download.assert_called_once()
|
||||
|
||||
@patch('src.core.SeriesApp.Loaders')
|
||||
@patch('src.core.SeriesApp.SerieScanner')
|
||||
@@ -182,7 +182,7 @@ class TestSeriesAppDownload:
|
||||
callback(0.5)
|
||||
callback(1.0)
|
||||
|
||||
app.loader.Download = Mock(side_effect=mock_download)
|
||||
app.loader.download = Mock(side_effect=mock_download)
|
||||
progress_callback = Mock()
|
||||
|
||||
# Perform download
|
||||
@@ -215,7 +215,7 @@ class TestSeriesAppDownload:
|
||||
# Simulate cancellation by raising InterruptedError
|
||||
raise InterruptedError("Download cancelled by user")
|
||||
|
||||
app.loader.Download = Mock(side_effect=mock_download_cancelled)
|
||||
app.loader.download = Mock(side_effect=mock_download_cancelled)
|
||||
|
||||
# Set cancel flag before calling (will be reset by download())
|
||||
# but the mock will raise InterruptedError anyway
|
||||
@@ -246,7 +246,7 @@ class TestSeriesAppDownload:
|
||||
app = SeriesApp(test_dir, error_callback=error_callback)
|
||||
|
||||
# Make download fail
|
||||
app.loader.Download = Mock(
|
||||
app.loader.download = Mock(
|
||||
side_effect=RuntimeError("Download failed")
|
||||
)
|
||||
|
||||
@@ -308,15 +308,15 @@ class TestSeriesAppReScan:
|
||||
app = SeriesApp(test_dir, progress_callback=progress_callback)
|
||||
|
||||
# Mock scanner
|
||||
app.SerieScanner.GetTotalToScan = Mock(return_value=3)
|
||||
app.SerieScanner.Reinit = Mock()
|
||||
app.SerieScanner.get_total_to_scan = Mock(return_value=3)
|
||||
app.SerieScanner.reinit = Mock()
|
||||
|
||||
def mock_scan(callback):
|
||||
callback("folder1", 1)
|
||||
callback("folder2", 2)
|
||||
callback("folder3", 3)
|
||||
|
||||
app.SerieScanner.Scan = Mock(side_effect=mock_scan)
|
||||
app.SerieScanner.scan = Mock(side_effect=mock_scan)
|
||||
|
||||
# Perform rescan
|
||||
result = app.ReScan()
|
||||
@@ -336,14 +336,14 @@ class TestSeriesAppReScan:
|
||||
app = SeriesApp(test_dir)
|
||||
|
||||
# Mock scanner
|
||||
app.SerieScanner.GetTotalToScan = Mock(return_value=3)
|
||||
app.SerieScanner.Reinit = Mock()
|
||||
app.SerieScanner.get_total_to_scan = Mock(return_value=3)
|
||||
app.SerieScanner.reinit = Mock()
|
||||
|
||||
def mock_scan(callback):
|
||||
app._cancel_flag = True
|
||||
callback("folder1", 1)
|
||||
|
||||
app.SerieScanner.Scan = Mock(side_effect=mock_scan)
|
||||
app.SerieScanner.scan = Mock(side_effect=mock_scan)
|
||||
|
||||
# Perform rescan
|
||||
result = app.ReScan()
|
||||
|
||||
Reference in New Issue
Block a user