diff --git a/Tests/video_system/download_tester.py b/Tests/video_system/download_tester.py index 052cd9f..3b4c1b6 100644 --- a/Tests/video_system/download_tester.py +++ b/Tests/video_system/download_tester.py @@ -1,4 +1,6 @@ -from src.downloader import VIDEO_RETURN_TYPE +import os +import requests +from src.downloader import VIDEO_RETURN_TYPE, VideoFile class DownloadTester: @@ -6,16 +8,18 @@ def download_single_video_test(self, videos: VIDEO_RETURN_TYPE, should_be_path: assert len(videos) == 1 video = videos[0] - with open(video.path, "rb") as downloaded, open( - should_be_path, "rb" - ) as should_be: - assert downloaded.read() == should_be.read(), "Downloaded file does not match the expected file" + self._test_download(video, should_be_path) def download_multiple_video_test(self, videos: VIDEO_RETURN_TYPE, should_be_paths: list[str]): assert len(videos) == len(should_be_paths), f"len(videos)={len(videos)} len(should_be_paths)={len(should_be_paths)}" for video, should_be_path in zip(videos, should_be_paths): - with open(video.path, "rb") as downloaded, open( - should_be_path, "rb" + self._test_download(video, should_be_path) + + + def _test_download(self, video: VideoFile, should_be_path: str): + with open(video.path, "rb") as downloaded, open( + should_be_path, "rb" # change to "wb" to run fix tests ) as should_be: - assert downloaded.read() == should_be.read(), "Downloaded file does not match the expected file" + # should_be.write(downloaded.read()) # uncomment to fix tests + assert downloaded.read() == should_be.read(), "Downloaded file does not match the expected file"