1
0
Fork 0
mirror of synced 2024-06-03 02:44:39 +12:00
bulk-downloader-for-reddit/tests/site_downloaders/test_direct.py

26 lines
818 B
Python
Raw Normal View History

2021-02-27 11:30:52 +13:00
#!/usr/bin/env python3
# coding=utf-8
from unittest.mock import Mock
import pytest
2021-04-12 19:58:32 +12:00
from bdfr.resource import Resource
from bdfr.site_downloaders.direct import Direct
2021-02-27 11:30:52 +13:00
@pytest.mark.online
@pytest.mark.parametrize(('test_url', 'expected_hash'), (
('https://giant.gfycat.com/DefinitiveCanineCrayfish.mp4', '48f9bd4dbec1556d7838885612b13b39'),
('https://giant.gfycat.com/DazzlingSilkyIguana.mp4', '808941b48fc1e28713d36dd7ed9dc648'),
))
def test_download_resource(test_url: str, expected_hash: str):
2021-03-26 00:51:31 +13:00
mock_submission = Mock()
2021-02-27 11:30:52 +13:00
mock_submission.url = test_url
test_site = Direct(mock_submission)
resources = test_site.find_resources()
assert len(resources) == 1
assert isinstance(resources[0], Resource)
2021-07-27 15:39:49 +12:00
resources[0].download()
2021-02-27 11:30:52 +13:00
assert resources[0].hash.hexdigest() == expected_hash