diff options
| author | Shyam Sunder | 2020-04-02 16:17:26 -0400 |
|---|---|---|
| committer | Shyam Sunder | 2020-04-03 13:11:54 -0400 |
| commit | 99a69333e656fcbf7acf55f8593cf2a70781fc6d (patch) | |
| tree | 1b858da2bdb7f5af9e39ee95358b569649ddd016 /server/szurubooru/tests/func | |
| parent | 08e62ec8853d7564ac718471be7fd32739a0bf90 (diff) | |
server/posts/upload: Add youtube-dl functionality
allows for video-based posts to be created by using youtube-dl
on the server. Access is controlled with the 'uploads:use_downloader'
permission.
Diffstat (limited to 'server/szurubooru/tests/func')
| -rw-r--r-- | server/szurubooru/tests/func/test_net.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/server/szurubooru/tests/func/test_net.py b/server/szurubooru/tests/func/test_net.py index fb149b0..43f7c28 100644 --- a/server/szurubooru/tests/func/test_net.py +++ b/server/szurubooru/tests/func/test_net.py @@ -1,4 +1,7 @@ +import pytest +from szurubooru.errors import ThirdPartyError from szurubooru.func import net +from szurubooru.func.util import get_sha1 def test_download(config_injector): @@ -47,3 +50,26 @@ def test_download(config_injector): actual_content = net.download(url) assert actual_content == expected_content + + +def test_video_download(tmpdir, config_injector): + config_injector({ + 'user_agent': None, + 'data_dir': str(tmpdir.mkdir('data')) + }) + url = 'https://www.youtube.com/watch?v=C0DPdy98e4c' + expected_sha1 = '508f89ee85bc6186e18cfaa4f4d0279bcf2418ab' + + actual_content = net.download(url, use_video_downloader=True) + assert get_sha1(actual_content) == expected_sha1 + + +def test_failed_video_download(tmpdir, config_injector): + config_injector({ + 'user_agent': None, + 'data_dir': str(tmpdir.mkdir('data')) + }) + url = 'http://info.cern.ch/hypertext/WWW/TheProject.html' + + with pytest.raises(ThirdPartyError): + net.download(url, use_video_downloader=True) |