first e2e test
This commit is contained in:
parent
d8b2782adc
commit
ae01113cdf
3 changed files with 25 additions and 6 deletions
|
|
@ -0,0 +1,7 @@
|
|||
# Add test modules to the system path so pycharm auto-imports work
|
||||
import os
|
||||
import sys
|
||||
|
||||
PROJECT_PATH = os.getcwd()
|
||||
TESTS_PATH = os.path.join(PROJECT_PATH, "tests")
|
||||
sys.path.append(TESTS_PATH)
|
||||
|
|
@ -19,9 +19,13 @@ class ExpectedDownload:
|
|||
"""
|
||||
for relative_path, expected_md5_hash in self.expected_md5_file_hashes.items():
|
||||
full_path = Path(relative_directory) / relative_path
|
||||
assert os.path.isfile(full_path), f"Expected {str(relative_path)} to be a file but it is not"
|
||||
assert os.path.isfile(
|
||||
full_path
|
||||
), f"Expected {str(relative_path)} to be a file but it is not"
|
||||
|
||||
with open(full_path, "rb") as file:
|
||||
md5_hash = hashlib.md5(file.read()).hexdigest()
|
||||
|
||||
assert md5_hash == expected_md5_hash, f"MD5 hash for {str(relative_path)} does not match"
|
||||
assert (
|
||||
md5_hash == expected_md5_hash
|
||||
), f"MD5 hash for {str(relative_path)} does not match"
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@ import tempfile
|
|||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from config.config_file import ConfigFile
|
||||
from config.subscription import SubscriptionValidator
|
||||
from e2e.expected_download import ExpectedDownload
|
||||
|
||||
from ytdl_sub.config.config_file import ConfigFile
|
||||
from ytdl_sub.config.subscription import SubscriptionValidator
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def output_directory():
|
||||
|
|
@ -55,7 +56,7 @@ def full_channel_subscription(config, subscription_name, subscription_dict):
|
|||
|
||||
@pytest.fixture
|
||||
def expected_full_channel_download():
|
||||
# turn of black formatter here for readability
|
||||
# turn off black formatter here for readability
|
||||
# fmt: off
|
||||
return ExpectedDownload(
|
||||
expected_md5_file_hashes={
|
||||
|
|
@ -121,6 +122,13 @@ def expected_full_channel_download():
|
|||
|
||||
|
||||
class TestChannelAsKodiTvShow:
|
||||
def test_full_channel_download(self, full_channel_subscription, expected_full_channel_download, output_directory):
|
||||
"""
|
||||
Downloads my old minecraft youtube channel. Ensure the above files exist and have the
|
||||
expected md5 file hashes.
|
||||
"""
|
||||
|
||||
def test_full_channel_download(
|
||||
self, full_channel_subscription, expected_full_channel_download, output_directory
|
||||
):
|
||||
full_channel_subscription.download()
|
||||
expected_full_channel_download.assert_files_exist(relative_directory=output_directory)
|
||||
|
|
|
|||
Loading…
Reference in a new issue