From d1c0a7ece22b707dacefc3563d90850a74568f6e Mon Sep 17 00:00:00 2001 From: Serene-Arc Date: Sat, 27 Feb 2021 08:30:52 +1000 Subject: [PATCH] Add test for downloader Direct --- .../tests/downloaders/test_direct.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 bulkredditdownloader/tests/downloaders/test_direct.py diff --git a/bulkredditdownloader/tests/downloaders/test_direct.py b/bulkredditdownloader/tests/downloaders/test_direct.py new file mode 100644 index 0000000..32cc483 --- /dev/null +++ b/bulkredditdownloader/tests/downloaders/test_direct.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +# coding=utf-8 + +from unittest.mock import Mock + +import pytest + +from bulkredditdownloader.resource import Resource +from bulkredditdownloader.site_downloaders.direct import Direct + + +@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): + mock_submission = Mock + mock_submission.url = test_url + test_site = Direct(mock_submission) + resources = test_site.find_resources() + assert len(resources) == 1 + assert isinstance(resources[0], Resource) + resources[0].download() + assert resources[0].hash.hexdigest() == expected_hash