Fix Redgifs tests
This commit is contained in:
parent
7bd957aafa
commit
5c343ef790
1 changed files with 14 additions and 11 deletions
|
@ -2,6 +2,7 @@
|
||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
|
||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
|
import re
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -12,24 +13,26 @@ from bdfr.site_downloaders.redgifs import Redgifs
|
||||||
@pytest.mark.online
|
@pytest.mark.online
|
||||||
@pytest.mark.parametrize(('test_url', 'expected'), (
|
@pytest.mark.parametrize(('test_url', 'expected'), (
|
||||||
('https://redgifs.com/watch/frighteningvictorioussalamander',
|
('https://redgifs.com/watch/frighteningvictorioussalamander',
|
||||||
{'https://thumbs3.redgifs.com/FrighteningVictoriousSalamander.mp4'}),
|
{'FrighteningVictoriousSalamander.mp4'}),
|
||||||
('https://redgifs.com/watch/springgreendecisivetaruca',
|
('https://redgifs.com/watch/springgreendecisivetaruca',
|
||||||
{'https://thumbs3.redgifs.com/SpringgreenDecisiveTaruca.mp4'}),
|
{'SpringgreenDecisiveTaruca.mp4'}),
|
||||||
('https://www.redgifs.com/watch/palegoldenrodrawhalibut',
|
('https://www.redgifs.com/watch/palegoldenrodrawhalibut',
|
||||||
{'https://thumbs3.redgifs.com/PalegoldenrodRawHalibut.mp4'}),
|
{'PalegoldenrodRawHalibut.mp4'}),
|
||||||
('https://redgifs.com/watch/hollowintentsnowyowl',
|
('https://redgifs.com/watch/hollowintentsnowyowl',
|
||||||
{'https://thumbs3.redgifs.com/HollowIntentSnowyowl-large.jpg'}),
|
{'HollowIntentSnowyowl-large.jpg'}),
|
||||||
('https://www.redgifs.com/watch/lustrousstickywaxwing',
|
('https://www.redgifs.com/watch/lustrousstickywaxwing',
|
||||||
{'https://thumbs3.redgifs.com/EntireEnchantingHypsilophodon-large.jpg',
|
{'EntireEnchantingHypsilophodon-large.jpg',
|
||||||
'https://thumbs3.redgifs.com/FancyMagnificentAdamsstaghornedbeetle-large.jpg',
|
'FancyMagnificentAdamsstaghornedbeetle-large.jpg',
|
||||||
'https://thumbs3.redgifs.com/LustrousStickyWaxwing-large.jpg',
|
'LustrousStickyWaxwing-large.jpg',
|
||||||
'https://thumbs3.redgifs.com/ParchedWindyArmyworm-large.jpg',
|
'ParchedWindyArmyworm-large.jpg',
|
||||||
'https://thumbs3.redgifs.com/ThunderousColorlessErmine-large.jpg',
|
'ThunderousColorlessErmine-large.jpg',
|
||||||
'https://thumbs3.redgifs.com/UnripeUnkemptWoodpecker-large.jpg'}),
|
'UnripeUnkemptWoodpecker-large.jpg'}),
|
||||||
))
|
))
|
||||||
def test_get_link(test_url: str, expected: set[str]):
|
def test_get_link(test_url: str, expected: set[str]):
|
||||||
result = Redgifs._get_link(test_url)
|
result = Redgifs._get_link(test_url)
|
||||||
assert result == expected
|
result = list(result)
|
||||||
|
patterns = [r'https://thumbs\d\.redgifs\.com/' + e + r'.*' for e in expected]
|
||||||
|
assert all([re.match(p, r) for p in patterns] for r in result)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.online
|
@pytest.mark.online
|
||||||
|
|
Loading…
Reference in a new issue