ytdl-sub/tests/e2e/plugins/test_file_convert.py
Jesse Bannon 10b58264ea
[BACKEND] Update music video example with url download strategy (#312)
* [DOCS] document file __preset__

* [REFACTOR] Use `download` type in examples

* TODO: download strategy docs, validate fixtures, fix playlist test

* playlist fixed, fixtures look good

* download strategy docs, fix tests

* better docs

* lint

* yt fixed

* split chapters fixed

* fix video

* better docs

* lint
2022-11-11 08:54:07 -08:00

47 lines
1.5 KiB
Python

import pytest
from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches
from ytdl_sub.subscriptions.subscription import Subscription
@pytest.fixture
def preset_dict(output_directory):
return {
"preset": "music_video",
"download": {"url": "https://www.youtube.com/watch?v=2zYF9JLHDmA"},
"output_options": {"output_directory": output_directory},
# download the worst format so it is fast
"ytdl_options": {
"postprocessor_args": {"ffmpeg": ["-bitexact"]}, # Must add this for reproducibility
},
"file_convert": {"convert_to": "mp4"},
}
class TestFileConvert:
@pytest.mark.parametrize("dry_run", [True, False])
def test_file_convert(
self,
music_video_config,
preset_dict,
output_directory,
dry_run,
):
subscription = Subscription.from_dict(
config=music_video_config,
preset_name="file_convert_test",
preset_dict=preset_dict,
)
transaction_log = subscription.download(dry_run=dry_run)
assert_transaction_log_matches(
output_directory=output_directory,
transaction_log=transaction_log,
transaction_log_summary_file_name="plugins/file_convert/output.txt",
)
assert_expected_downloads(
output_directory=output_directory,
dry_run=dry_run,
expected_download_summary_file_name="plugins/file_convert/output.json",
)