Refactor and optimise some tests (#245)

* Rename to follow actual directory name

* Remove unnecessary Reddit call from test

* Refactor test to reduce duplication

* Parameterise some tests

* Standardise formatting
This commit is contained in:
Serene
2021-04-04 03:25:58 +10:00
committed by Ali Parlakci
parent a05fa1a965
commit 2385867afb
19 changed files with 189 additions and 133 deletions

View File

@@ -0,0 +1,26 @@
#!/usr/bin/env python3
# coding=utf-8
from unittest.mock import MagicMock
import pytest
from bulkredditdownloader.resource import Resource
from bulkredditdownloader.site_downloaders.youtube import Youtube
@pytest.mark.online
@pytest.mark.slow
@pytest.mark.parametrize(('test_url', 'expected_hash'), (
('https://www.youtube.com/watch?v=uSm2VDgRIUs', '3c79a62898028987f94161e0abccbddf'),
('https://www.youtube.com/watch?v=m-tKnjFwleU', '61651cc6f53782af50030c0a7dd0b6f6'),
))
def test_find_resources(test_url: str, expected_hash: str):
test_submission = MagicMock()
test_submission.url = test_url
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