diff options
| author | Shyam Sunder | 2020-04-07 15:14:53 -0400 |
|---|---|---|
| committer | Shyam Sunder | 2020-04-07 15:14:53 -0400 |
| commit | 377fe52072b202dda09cf36f4fa38600749f7a42 (patch) | |
| tree | 5eb61065b0d077a927b0cdea8121052cfd6e535e /server/szurubooru/tests | |
| parent | cd6683c2d81accd07962739b9835602e4c8d6b18 (diff) | |
server/posts/upload: refactor youtube-dl caller code to fix some bugs
Diffstat (limited to 'server/szurubooru/tests')
| -rw-r--r-- | server/szurubooru/tests/func/test_net.py | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/server/szurubooru/tests/func/test_net.py b/server/szurubooru/tests/func/test_net.py index 64951e2..7fe14b6 100644 --- a/server/szurubooru/tests/func/test_net.py +++ b/server/szurubooru/tests/func/test_net.py @@ -58,31 +58,30 @@ def test_download(): assert actual_content == expected_content -def test_too_large_download(): +@pytest.mark.parametrize('url', [ + 'https://samples.ffmpeg.org/MPEG-4/video.mp4', +]) +def test_too_large_download(url): pytest.xfail('Download limit not implemented yet') - url = 'https://samples.ffmpeg.org/MPEG-4/video.mp4' - - with pytest.raises(errors.DownloadTooLargeError): + with pytest.raises(errors.ProcessingError): net.download(url) -def test_video_download(): - url = 'https://www.youtube.com/watch?v=C0DPdy98e4c' - expected_sha1 = '365af1c8f59c6865e1a84c6e13e3e25ff89e0ba1' - +@pytest.mark.parametrize('url,expected_sha1', [ + ('https://www.youtube.com/watch?v=C0DPdy98e4c', + '365af1c8f59c6865e1a84c6e13e3e25ff89e0ba1'), + ('https://gfycat.com/immaterialchillyiberianmole', + '953000e81d7bd1da95ce264f872e7b6c4a6484be'), +]) +def test_video_download(url, expected_sha1): actual_content = net.download(url, use_video_downloader=True) assert get_sha1(actual_content) == expected_sha1 -def test_failed_video_download(): - url = 'https://samples.ffmpeg.org/flac/short.flac' - +@pytest.mark.parametrize('url', [ + 'https://samples.ffmpeg.org/flac/short.flac', # not a video + 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', # video too large +]) +def test_failed_video_download(url): with pytest.raises(errors.ThirdPartyError): net.download(url, use_video_downloader=True) - - -def test_too_large_video_download(): - url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' - - with pytest.raises(errors.DownloadTooLargeError): - net.download(url, use_video_downloader=True) |