Fix a crash when downloading a disabled pornhub video

This commit is contained in:
Serene-Arc
2021-11-05 13:23:55 +10:00
parent d25f3fe008
commit 801784c46d
2 changed files with 21 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ from unittest.mock import MagicMock
import pytest
from bdfr.exceptions import SiteDownloaderError
from bdfr.resource import Resource
from bdfr.site_downloaders.pornhub import PornHub
@@ -13,6 +14,7 @@ from bdfr.site_downloaders.pornhub import PornHub
@pytest.mark.slow
@pytest.mark.parametrize(('test_url', 'expected_hash'), (
('https://www.pornhub.com/view_video.php?viewkey=ph6074c59798497', 'd9b99e4ebecf2d8d67efe5e70d2acf8a'),
('https://www.pornhub.com/view_video.php?viewkey=ph5ede121f0d3f8', ''),
))
def test_find_resources_good(test_url: str, expected_hash: str):
test_submission = MagicMock()
@@ -23,3 +25,15 @@ def test_find_resources_good(test_url: str, expected_hash: str):
assert isinstance(resources[0], Resource)
resources[0].download()
assert resources[0].hash.hexdigest() == expected_hash
@pytest.mark.online
@pytest.mark.parametrize('test_url', (
'https://www.pornhub.com/view_video.php?viewkey=ph5ede121f0d3f8',
))
def test_find_resources_good(test_url: str):
test_submission = MagicMock()
test_submission.url = test_url
downloader = PornHub(test_submission)
with pytest.raises(SiteDownloaderError):
downloader.find_resources()