2021-02-28 17:52:20 +13:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# coding=utf-8
|
|
|
|
|
2021-04-04 05:25:58 +12:00
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
2021-02-28 17:52:20 +13:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from bulkredditdownloader.resource import Resource
|
|
|
|
from bulkredditdownloader.site_downloaders.youtube import Youtube
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.online
|
2021-03-13 18:11:59 +13:00
|
|
|
@pytest.mark.slow
|
2021-04-04 05:25:58 +12:00
|
|
|
@pytest.mark.parametrize(('test_url', 'expected_hash'), (
|
|
|
|
('https://www.youtube.com/watch?v=uSm2VDgRIUs', '3c79a62898028987f94161e0abccbddf'),
|
2021-04-05 18:12:05 +12:00
|
|
|
('https://www.youtube.com/watch?v=m-tKnjFwleU', '30314930d853afff8ebc7d8c36a5b833'),
|
2021-02-28 17:52:20 +13:00
|
|
|
))
|
2021-04-04 05:25:58 +12:00
|
|
|
def test_find_resources(test_url: str, expected_hash: str):
|
|
|
|
test_submission = MagicMock()
|
|
|
|
test_submission.url = test_url
|
2021-02-28 17:52:20 +13:00
|
|
|
downloader = Youtube(test_submission)
|
|
|
|
resources = downloader.find_resources()
|
|
|
|
assert len(resources) == 1
|
|
|
|
assert isinstance(resources[0], Resource)
|
|
|
|
resources[0].download()
|
|
|
|
assert resources[0].hash.hexdigest() == expected_hash
|