fix prebuilt tests
This commit is contained in:
parent
ad7ed4cb3b
commit
f7837c69ea
1 changed files with 75 additions and 76 deletions
|
|
@ -4,6 +4,7 @@ import tempfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
from typing import List
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
@ -126,85 +127,83 @@ def mock_download_collection_entries(
|
||||||
def _(**kwargs):
|
def _(**kwargs):
|
||||||
return mock_entry_dict_factory(**kwargs)
|
return mock_entry_dict_factory(**kwargs)
|
||||||
|
|
||||||
collection_1_entry_dicts = [
|
def _write_entries_to_working_dir(*args, **kwargs) -> List[Dict]:
|
||||||
_(
|
if (len(args[0].collection.urls.list) == 1) or (
|
||||||
uid="21-1",
|
"season.2" in kwargs["url"] and len(args[0].download_options.urls.list) > 1
|
||||||
upload_date="20210808",
|
):
|
||||||
playlist_index=1,
|
return [
|
||||||
playlist_count=4,
|
_(
|
||||||
is_youtube_channel=is_youtube_channel,
|
uid="21-1",
|
||||||
), # 1
|
upload_date="20210808",
|
||||||
_(
|
playlist_index=1,
|
||||||
uid="20-1",
|
playlist_count=4,
|
||||||
upload_date="20200808",
|
is_youtube_channel=is_youtube_channel,
|
||||||
playlist_index=2,
|
), # 1
|
||||||
playlist_count=4,
|
_(
|
||||||
is_youtube_channel=is_youtube_channel,
|
uid="20-1",
|
||||||
), # 2 98
|
upload_date="20200808",
|
||||||
_(
|
playlist_index=2,
|
||||||
uid="20-2",
|
playlist_count=4,
|
||||||
upload_date="20200808",
|
is_youtube_channel=is_youtube_channel,
|
||||||
playlist_index=3,
|
), # 2 98
|
||||||
playlist_count=4,
|
_(
|
||||||
is_youtube_channel=is_youtube_channel,
|
uid="20-2",
|
||||||
), # 1 99
|
upload_date="20200808",
|
||||||
_(
|
playlist_index=3,
|
||||||
uid="20-3",
|
playlist_count=4,
|
||||||
upload_date="20200807",
|
is_youtube_channel=is_youtube_channel,
|
||||||
playlist_index=4,
|
), # 1 99
|
||||||
playlist_count=4,
|
_(
|
||||||
is_youtube_channel=is_youtube_channel,
|
uid="20-3",
|
||||||
),
|
upload_date="20200807",
|
||||||
]
|
playlist_index=4,
|
||||||
collection_2_entry_dicts = [
|
playlist_count=4,
|
||||||
# 20-3 should resolve to collection 1 (which is season 2)
|
is_youtube_channel=is_youtube_channel,
|
||||||
_(
|
),
|
||||||
uid="20-3",
|
]
|
||||||
upload_date="20200807",
|
return [
|
||||||
playlist_index=1,
|
# 20-3 should resolve to collection 1 (which is season 2)
|
||||||
playlist_count=5,
|
_(
|
||||||
is_youtube_channel=is_youtube_channel,
|
uid="20-3",
|
||||||
),
|
upload_date="20200807",
|
||||||
_(
|
playlist_index=1,
|
||||||
uid="20-4",
|
playlist_count=5,
|
||||||
upload_date="20200806",
|
is_youtube_channel=is_youtube_channel,
|
||||||
playlist_index=2,
|
),
|
||||||
playlist_count=5,
|
_(
|
||||||
is_youtube_channel=is_youtube_channel,
|
uid="20-4",
|
||||||
),
|
upload_date="20200806",
|
||||||
_(
|
playlist_index=2,
|
||||||
uid="20-5",
|
playlist_count=5,
|
||||||
upload_date="20200706",
|
is_youtube_channel=is_youtube_channel,
|
||||||
playlist_index=3,
|
),
|
||||||
playlist_count=5,
|
_(
|
||||||
is_youtube_channel=is_youtube_channel,
|
uid="20-5",
|
||||||
),
|
upload_date="20200706",
|
||||||
_(
|
playlist_index=3,
|
||||||
uid="20-6",
|
playlist_count=5,
|
||||||
upload_date="20200706",
|
is_youtube_channel=is_youtube_channel,
|
||||||
playlist_index=4,
|
),
|
||||||
playlist_count=5,
|
_(
|
||||||
is_youtube_channel=is_youtube_channel,
|
uid="20-6",
|
||||||
),
|
upload_date="20200706",
|
||||||
_(
|
playlist_index=4,
|
||||||
uid="20-7",
|
playlist_count=5,
|
||||||
upload_date="20200606",
|
is_youtube_channel=is_youtube_channel,
|
||||||
playlist_index=5,
|
),
|
||||||
playlist_count=5,
|
_(
|
||||||
is_youtube_channel=is_youtube_channel,
|
uid="20-7",
|
||||||
),
|
upload_date="20200606",
|
||||||
]
|
playlist_index=5,
|
||||||
|
playlist_count=5,
|
||||||
|
is_youtube_channel=is_youtube_channel,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
with patch.object(
|
with patch.object(
|
||||||
Downloader, "extract_info_via_info_json"
|
Downloader, "extract_info_via_info_json", new=_write_entries_to_working_dir
|
||||||
) as mock_download_metadata, patch.object(
|
), patch.object(Downloader, "_extract_entry_info_with_retry", new=lambda _, entry: entry):
|
||||||
Downloader, "_extract_entry_info_with_retry", new=lambda _, entry: entry
|
|
||||||
):
|
|
||||||
# Stub out metadata. TODO: update this if we do metadata plugins
|
# Stub out metadata. TODO: update this if we do metadata plugins
|
||||||
mock_download_metadata.side_effect = [
|
|
||||||
collection_1_entry_dicts,
|
|
||||||
collection_2_entry_dicts,
|
|
||||||
]
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
return _mock_download_collection_entries_factory
|
return _mock_download_collection_entries_factory
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue