1
0
Fork 0
mirror of synced 2024-06-02 18:34:37 +12:00
bulk-downloader-for-reddit/tests/site_downloaders/test_gfycat.py

42 lines
1.2 KiB
Python
Raw Normal View History

#!/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.gfycat import Gfycat
@pytest.mark.online
2022-12-03 18:11:17 +13:00
@pytest.mark.parametrize(
("test_url", "expected_url"),
(
("https://gfycat.com/definitivecaninecrayfish", "https://giant.gfycat.com/DefinitiveCanineCrayfish.mp4"),
("https://gfycat.com/dazzlingsilkyiguana", "https://giant.gfycat.com/DazzlingSilkyIguana.mp4"),
),
)
def test_get_link(test_url: str, expected_url: str):
result = Gfycat._get_link(test_url)
2022-02-18 15:49:46 +13:00
assert result.pop() == expected_url
@pytest.mark.online
2022-12-03 18:11:17 +13:00
@pytest.mark.parametrize(
("test_url", "expected_hash"),
(
("https://gfycat.com/definitivecaninecrayfish", "48f9bd4dbec1556d7838885612b13b39"),
("https://gfycat.com/dazzlingsilkyiguana", "808941b48fc1e28713d36dd7ed9dc648"),
),
)
def test_download_resource(test_url: str, expected_hash: str):
2021-03-31 14:07:02 +13:00
mock_submission = Mock()
mock_submission.url = test_url
test_site = Gfycat(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()
assert resources[0].hash.hexdigest() == expected_hash