Exclude slow integration test from default pytest

This commit is contained in:
Andrew Beveridge committed 2025-04-01 12:33:22 -04:00
1 parent d71047bace
commit ec08054d99
4 files changed
+26 -20

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
[pytest]
markers =
slow: marks tests as slow (deselect with '-m "not slow"')
asyncio: mark test as async
# By default, skip slow tests
addopts = -m "not slow"
+1
View File
@@ -97,6 +97,7 @@ async def test_karaoke_prep_integration():
@pytest.mark.asyncio
@pytest.mark.slow
async def test_full_cli_integration(tmp_path, mocker):
"""Tests the full CLI workflow by calling async_main directly with mocked sys.argv."""
+7 -3
View File
@@ -152,9 +152,13 @@ class TestAudio:
# 6. backing vocals path check (_separate_backing_vocals)
# 7. combined instrumental path check (_generate_combined_instrumentals)
# Then True for normalization checks:
# 8. clean instrumental path check (in _normalize_audio_files)
# 9. combined instrumental path check (in _normalize_audio_files)
mock_file_exists.side_effect = [False] * 7 + [True] * 2
# 8. backing lead vocals path check (inner loop in _separate_backing_vocals)
# 9. backing backing vocals path check (inner loop in _separate_backing_vocals)
# 10. combined instrumental path check (_generate_combined_instrumentals)
# Then True for normalization checks:
# 11. clean instrumental path check (in _normalize_audio_files)
# 12. combined instrumental path check (in _normalize_audio_files)
mock_file_exists.side_effect = [False] * 9 + [True] * 2 # Adjusted from 7 to 9 False values
# Configure the mock datetime object
mock_datetime.now.return_value = dt.datetime.fromisoformat("2023-01-01T12:00:00")
+11 -17
View File
@@ -94,25 +94,19 @@ class TestMetadata:
with patch('karaoke_prep.karaoke_prep.ydl') as mock_ydl_context:
# Configure the context manager mock
mock_ydl_context.return_value.__enter__.return_value = mock_ydl_instance
# Call the method that performs the search
basic_karaoke_prep.extract_info_for_online_media(input_artist=artist, input_title=title)
# Verify ydl was instantiated
mock_ydl_context.assert_called_once()
# Verify extract_info was called
mock_ydl_instance.extract_info.assert_called_once()
# The method itself raises IndexError when accessing ["entries"][0]
# The previous call already triggered this. We just need to assert it happened.
# No need to re-patch or re-call. The initial call within the first 'with' block
# should have raised the error if the mock was set up correctly.
# Let's verify the exception is raised by calling the method within the raises block.
# Assert that calling the method with no results raises an IndexError
with pytest.raises(IndexError):
# Call the method again, this time expecting the error
basic_karaoke_prep.extract_info_for_online_media(input_artist=artist, input_title=title)
# Verify ydl was instantiated with correct options
expected_ydl_opts = {"quiet": "True", "format": "bestaudio", "noplaylist": "True", "extract_flat": True}
mock_ydl_context.assert_called_once_with(expected_ydl_opts)
# Verify extract_info was called with the correct arguments
expected_query = f"ytsearch1:{artist} {title}"
mock_ydl_instance.extract_info.assert_called_once_with(expected_query, download=False)
def test_parse_single_track_metadata_complete(self, basic_karaoke_prep):
"""Test parsing metadata from extracted info with complete information."""
basic_karaoke_prep.extracted_info = {