Format according to the black standard
This commit is contained in:
@@ -10,22 +10,23 @@ from bdfr.site_downloaders.fallback_downloaders.ytdlp_fallback import YtdlpFallb
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize(('test_url', 'expected'), (
|
||||
('https://www.reddit.com/r/specializedtools/comments/n2nw5m/bamboo_splitter/', True),
|
||||
('https://www.youtube.com/watch?v=P19nvJOmqCc', True),
|
||||
('https://www.example.com/test', False),
|
||||
('https://milesmatrix.bandcamp.com/album/la-boum/', False),
|
||||
('https://v.redd.it/dlr54z8p182a1', True),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected"),
|
||||
(
|
||||
("https://www.reddit.com/r/specializedtools/comments/n2nw5m/bamboo_splitter/", True),
|
||||
("https://www.youtube.com/watch?v=P19nvJOmqCc", True),
|
||||
("https://www.example.com/test", False),
|
||||
("https://milesmatrix.bandcamp.com/album/la-boum/", False),
|
||||
("https://v.redd.it/dlr54z8p182a1", True),
|
||||
),
|
||||
)
|
||||
def test_can_handle_link(test_url: str, expected: bool):
|
||||
result = YtdlpFallback.can_handle_link(test_url)
|
||||
assert result == expected
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize('test_url', (
|
||||
'https://milesmatrix.bandcamp.com/album/la-boum/',
|
||||
))
|
||||
@pytest.mark.parametrize("test_url", ("https://milesmatrix.bandcamp.com/album/la-boum/",))
|
||||
def test_info_extraction_bad(test_url: str):
|
||||
with pytest.raises(NotADownloadableLinkError):
|
||||
YtdlpFallback.get_video_attributes(test_url)
|
||||
@@ -33,12 +34,18 @@ def test_info_extraction_bad(test_url: str):
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.parametrize(('test_url', 'expected_hash'), (
|
||||
('https://streamable.com/dt46y', 'b7e465adaade5f2b6d8c2b4b7d0a2878'),
|
||||
('https://streamable.com/t8sem', '49b2d1220c485455548f1edbc05d4ecf'),
|
||||
('https://www.reddit.com/r/specializedtools/comments/n2nw5m/bamboo_splitter/', '6c6ff46e04b4e33a755ae2a9b5a45ac5'),
|
||||
('https://v.redd.it/9z1dnk3xr5k61', '226cee353421c7aefb05c92424cc8cdd'),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected_hash"),
|
||||
(
|
||||
("https://streamable.com/dt46y", "b7e465adaade5f2b6d8c2b4b7d0a2878"),
|
||||
("https://streamable.com/t8sem", "49b2d1220c485455548f1edbc05d4ecf"),
|
||||
(
|
||||
"https://www.reddit.com/r/specializedtools/comments/n2nw5m/bamboo_splitter/",
|
||||
"6c6ff46e04b4e33a755ae2a9b5a45ac5",
|
||||
),
|
||||
("https://v.redd.it/9z1dnk3xr5k61", "226cee353421c7aefb05c92424cc8cdd"),
|
||||
),
|
||||
)
|
||||
def test_find_resources(test_url: str, expected_hash: str):
|
||||
test_submission = MagicMock()
|
||||
test_submission.url = test_url
|
||||
|
||||
@@ -10,10 +10,13 @@ from bdfr.site_downloaders.delay_for_reddit import DelayForReddit
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize(('test_url', 'expected_hash'), (
|
||||
('https://www.delayforreddit.com/dfr/calvin6123/MjU1Njc5NQ==', '3300f28c2f9358d05667985c9c04210d'),
|
||||
('https://www.delayforreddit.com/dfr/RoXs_26/NDAwMzAyOQ==', '09b7b01719dff45ab197bdc08b90f78a'),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected_hash"),
|
||||
(
|
||||
("https://www.delayforreddit.com/dfr/calvin6123/MjU1Njc5NQ==", "3300f28c2f9358d05667985c9c04210d"),
|
||||
("https://www.delayforreddit.com/dfr/RoXs_26/NDAwMzAyOQ==", "09b7b01719dff45ab197bdc08b90f78a"),
|
||||
),
|
||||
)
|
||||
def test_download_resource(test_url: str, expected_hash: str):
|
||||
mock_submission = Mock()
|
||||
mock_submission.url = test_url
|
||||
|
||||
@@ -10,10 +10,13 @@ from bdfr.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'),
|
||||
))
|
||||
@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
|
||||
|
||||
@@ -21,67 +21,82 @@ from bdfr.site_downloaders.youtube import Youtube
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize(('test_submission_url', 'expected_class'), (
|
||||
('https://www.reddit.com/r/TwoXChromosomes/comments/lu29zn/i_refuse_to_live_my_life'
|
||||
'_in_anything_but_comfort/', SelfPost),
|
||||
('https://i.redd.it/affyv0axd5k61.png', Direct),
|
||||
('https://i.imgur.com/bZx1SJQ.jpg', Imgur),
|
||||
('https://imgur.com/BuzvZwb.gifv', Imgur),
|
||||
('https://imgur.com/a/MkxAzeg', Imgur),
|
||||
('https://m.imgur.com/a/py3RW0j', Imgur),
|
||||
('https://www.reddit.com/gallery/lu93m7', Gallery),
|
||||
('https://gfycat.com/concretecheerfulfinwhale', Gfycat),
|
||||
('https://www.erome.com/a/NWGw0F09', Erome),
|
||||
('https://youtube.com/watch?v=Gv8Wz74FjVA', Youtube),
|
||||
('https://redgifs.com/watch/courageousimpeccablecanvasback', Redgifs),
|
||||
('https://www.gifdeliverynetwork.com/repulsivefinishedandalusianhorse', Redgifs),
|
||||
('https://youtu.be/DevfjHOhuFc', Youtube),
|
||||
('https://m.youtube.com/watch?v=kr-FeojxzUM', Youtube),
|
||||
('https://dynasty-scans.com/system/images_images/000/017/819/original/80215103_p0.png?1612232781', Direct),
|
||||
('https://v.redd.it/9z1dnk3xr5k61', VReddit),
|
||||
('https://streamable.com/dt46y', YtdlpFallback),
|
||||
('https://vimeo.com/channels/31259/53576664', YtdlpFallback),
|
||||
('http://video.pbs.org/viralplayer/2365173446/', YtdlpFallback),
|
||||
('https://www.pornhub.com/view_video.php?viewkey=ph5a2ee0461a8d0', PornHub),
|
||||
('https://www.patreon.com/posts/minecart-track-59346560', Gallery),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_submission_url", "expected_class"),
|
||||
(
|
||||
(
|
||||
"https://www.reddit.com/r/TwoXChromosomes/comments/lu29zn/i_refuse_to_live_my_life"
|
||||
"_in_anything_but_comfort/",
|
||||
SelfPost,
|
||||
),
|
||||
("https://i.redd.it/affyv0axd5k61.png", Direct),
|
||||
("https://i.imgur.com/bZx1SJQ.jpg", Imgur),
|
||||
("https://imgur.com/BuzvZwb.gifv", Imgur),
|
||||
("https://imgur.com/a/MkxAzeg", Imgur),
|
||||
("https://m.imgur.com/a/py3RW0j", Imgur),
|
||||
("https://www.reddit.com/gallery/lu93m7", Gallery),
|
||||
("https://gfycat.com/concretecheerfulfinwhale", Gfycat),
|
||||
("https://www.erome.com/a/NWGw0F09", Erome),
|
||||
("https://youtube.com/watch?v=Gv8Wz74FjVA", Youtube),
|
||||
("https://redgifs.com/watch/courageousimpeccablecanvasback", Redgifs),
|
||||
("https://www.gifdeliverynetwork.com/repulsivefinishedandalusianhorse", Redgifs),
|
||||
("https://youtu.be/DevfjHOhuFc", Youtube),
|
||||
("https://m.youtube.com/watch?v=kr-FeojxzUM", Youtube),
|
||||
("https://dynasty-scans.com/system/images_images/000/017/819/original/80215103_p0.png?1612232781", Direct),
|
||||
("https://v.redd.it/9z1dnk3xr5k61", VReddit),
|
||||
("https://streamable.com/dt46y", YtdlpFallback),
|
||||
("https://vimeo.com/channels/31259/53576664", YtdlpFallback),
|
||||
("http://video.pbs.org/viralplayer/2365173446/", YtdlpFallback),
|
||||
("https://www.pornhub.com/view_video.php?viewkey=ph5a2ee0461a8d0", PornHub),
|
||||
("https://www.patreon.com/posts/minecart-track-59346560", Gallery),
|
||||
),
|
||||
)
|
||||
def test_factory_lever_good(test_submission_url: str, expected_class: BaseDownloader, reddit_instance: praw.Reddit):
|
||||
result = DownloadFactory.pull_lever(test_submission_url)
|
||||
assert result is expected_class
|
||||
|
||||
|
||||
@pytest.mark.parametrize('test_url', (
|
||||
'random.com',
|
||||
'bad',
|
||||
'https://www.google.com/',
|
||||
'https://www.google.com',
|
||||
'https://www.google.com/test',
|
||||
'https://www.google.com/test/',
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
"test_url",
|
||||
(
|
||||
"random.com",
|
||||
"bad",
|
||||
"https://www.google.com/",
|
||||
"https://www.google.com",
|
||||
"https://www.google.com/test",
|
||||
"https://www.google.com/test/",
|
||||
),
|
||||
)
|
||||
def test_factory_lever_bad(test_url: str):
|
||||
with pytest.raises(NotADownloadableLinkError):
|
||||
DownloadFactory.pull_lever(test_url)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('test_url', 'expected'), (
|
||||
('www.test.com/test.png', 'test.com/test.png'),
|
||||
('www.test.com/test.png?test_value=random', 'test.com/test.png'),
|
||||
('https://youtube.com/watch?v=Gv8Wz74FjVA', 'youtube.com/watch'),
|
||||
('https://i.imgur.com/BuzvZwb.gifv', 'i.imgur.com/BuzvZwb.gifv'),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected"),
|
||||
(
|
||||
("www.test.com/test.png", "test.com/test.png"),
|
||||
("www.test.com/test.png?test_value=random", "test.com/test.png"),
|
||||
("https://youtube.com/watch?v=Gv8Wz74FjVA", "youtube.com/watch"),
|
||||
("https://i.imgur.com/BuzvZwb.gifv", "i.imgur.com/BuzvZwb.gifv"),
|
||||
),
|
||||
)
|
||||
def test_sanitise_url(test_url: str, expected: str):
|
||||
result = DownloadFactory.sanitise_url(test_url)
|
||||
assert result == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('test_url', 'expected'), (
|
||||
('www.example.com/test.asp', True),
|
||||
('www.example.com/test.html', True),
|
||||
('www.example.com/test.js', True),
|
||||
('www.example.com/test.xhtml', True),
|
||||
('www.example.com/test.mp4', False),
|
||||
('www.example.com/test.png', False),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected"),
|
||||
(
|
||||
("www.example.com/test.asp", True),
|
||||
("www.example.com/test.html", True),
|
||||
("www.example.com/test.js", True),
|
||||
("www.example.com/test.xhtml", True),
|
||||
("www.example.com/test.mp4", False),
|
||||
("www.example.com/test.png", False),
|
||||
),
|
||||
)
|
||||
def test_is_web_resource(test_url: str, expected: bool):
|
||||
result = DownloadFactory.is_web_resource(test_url)
|
||||
assert result == expected
|
||||
|
||||
@@ -9,31 +9,38 @@ from bdfr.site_downloaders.erome import Erome
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize(('test_url', 'expected_urls'), (
|
||||
('https://www.erome.com/a/vqtPuLXh', (
|
||||
r'https://[a-z]\d+.erome.com/\d{3}/vqtPuLXh/KH2qBT99_480p.mp4',
|
||||
)),
|
||||
('https://www.erome.com/a/ORhX0FZz', (
|
||||
r'https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/9IYQocM9_480p.mp4',
|
||||
r'https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/9eEDc8xm_480p.mp4',
|
||||
r'https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/EvApC7Rp_480p.mp4',
|
||||
r'https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/LruobtMs_480p.mp4',
|
||||
r'https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/TJNmSUU5_480p.mp4',
|
||||
r'https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/X11Skh6Z_480p.mp4',
|
||||
r'https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/bjlTkpn7_480p.mp4'
|
||||
)),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected_urls"),
|
||||
(
|
||||
("https://www.erome.com/a/vqtPuLXh", (r"https://[a-z]\d+.erome.com/\d{3}/vqtPuLXh/KH2qBT99_480p.mp4",)),
|
||||
(
|
||||
"https://www.erome.com/a/ORhX0FZz",
|
||||
(
|
||||
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/9IYQocM9_480p.mp4",
|
||||
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/9eEDc8xm_480p.mp4",
|
||||
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/EvApC7Rp_480p.mp4",
|
||||
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/LruobtMs_480p.mp4",
|
||||
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/TJNmSUU5_480p.mp4",
|
||||
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/X11Skh6Z_480p.mp4",
|
||||
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/bjlTkpn7_480p.mp4",
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_get_link(test_url: str, expected_urls: tuple[str]):
|
||||
result = Erome. _get_links(test_url)
|
||||
result = Erome._get_links(test_url)
|
||||
assert all([any([re.match(p, r) for r in result]) for p in expected_urls])
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.parametrize(('test_url', 'expected_hashes_len'), (
|
||||
('https://www.erome.com/a/vqtPuLXh', 1),
|
||||
('https://www.erome.com/a/4tP3KI6F', 1),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected_hashes_len"),
|
||||
(
|
||||
("https://www.erome.com/a/vqtPuLXh", 1),
|
||||
("https://www.erome.com/a/4tP3KI6F", 1),
|
||||
),
|
||||
)
|
||||
def test_download_resource(test_url: str, expected_hashes_len: int):
|
||||
# Can't compare hashes for this test, Erome doesn't return the exact same file from request to request so the hash
|
||||
# will change back and forth randomly
|
||||
|
||||
@@ -9,30 +9,39 @@ from bdfr.site_downloaders.gallery import Gallery
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize(('test_ids', 'expected'), (
|
||||
([
|
||||
{'media_id': '18nzv9ch0hn61'},
|
||||
{'media_id': 'jqkizcch0hn61'},
|
||||
{'media_id': 'k0fnqzbh0hn61'},
|
||||
{'media_id': 'm3gamzbh0hn61'},
|
||||
], {
|
||||
'https://i.redd.it/18nzv9ch0hn61.jpg',
|
||||
'https://i.redd.it/jqkizcch0hn61.jpg',
|
||||
'https://i.redd.it/k0fnqzbh0hn61.jpg',
|
||||
'https://i.redd.it/m3gamzbh0hn61.jpg'
|
||||
}),
|
||||
([
|
||||
{'media_id': '04vxj25uqih61'},
|
||||
{'media_id': '0fnx83kpqih61'},
|
||||
{'media_id': '7zkmr1wqqih61'},
|
||||
{'media_id': 'u37k5gxrqih61'},
|
||||
], {
|
||||
'https://i.redd.it/04vxj25uqih61.png',
|
||||
'https://i.redd.it/0fnx83kpqih61.png',
|
||||
'https://i.redd.it/7zkmr1wqqih61.png',
|
||||
'https://i.redd.it/u37k5gxrqih61.png'
|
||||
}),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_ids", "expected"),
|
||||
(
|
||||
(
|
||||
[
|
||||
{"media_id": "18nzv9ch0hn61"},
|
||||
{"media_id": "jqkizcch0hn61"},
|
||||
{"media_id": "k0fnqzbh0hn61"},
|
||||
{"media_id": "m3gamzbh0hn61"},
|
||||
],
|
||||
{
|
||||
"https://i.redd.it/18nzv9ch0hn61.jpg",
|
||||
"https://i.redd.it/jqkizcch0hn61.jpg",
|
||||
"https://i.redd.it/k0fnqzbh0hn61.jpg",
|
||||
"https://i.redd.it/m3gamzbh0hn61.jpg",
|
||||
},
|
||||
),
|
||||
(
|
||||
[
|
||||
{"media_id": "04vxj25uqih61"},
|
||||
{"media_id": "0fnx83kpqih61"},
|
||||
{"media_id": "7zkmr1wqqih61"},
|
||||
{"media_id": "u37k5gxrqih61"},
|
||||
],
|
||||
{
|
||||
"https://i.redd.it/04vxj25uqih61.png",
|
||||
"https://i.redd.it/0fnx83kpqih61.png",
|
||||
"https://i.redd.it/7zkmr1wqqih61.png",
|
||||
"https://i.redd.it/u37k5gxrqih61.png",
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_gallery_get_links(test_ids: list[dict], expected: set[str]):
|
||||
results = Gallery._get_links(test_ids)
|
||||
assert set(results) == expected
|
||||
@@ -40,32 +49,47 @@ def test_gallery_get_links(test_ids: list[dict], expected: set[str]):
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.reddit
|
||||
@pytest.mark.parametrize(('test_submission_id', 'expected_hashes'), (
|
||||
('m6lvrh', {
|
||||
'5c42b8341dd56eebef792e86f3981c6a',
|
||||
'8f38d76da46f4057bf2773a778e725ca',
|
||||
'f5776f8f90491c8b770b8e0a6bfa49b3',
|
||||
'fa1a43c94da30026ad19a9813a0ed2c2',
|
||||
}),
|
||||
('ljyy27', {
|
||||
'359c203ec81d0bc00e675f1023673238',
|
||||
'79262fd46bce5bfa550d878a3b898be4',
|
||||
'808c35267f44acb523ce03bfa5687404',
|
||||
'ec8b65bdb7f1279c4b3af0ea2bbb30c3',
|
||||
}),
|
||||
('obkflw', {
|
||||
'65163f685fb28c5b776e0e77122718be',
|
||||
'2a337eb5b13c34d3ca3f51b5db7c13e9',
|
||||
}),
|
||||
('rb3ub6', { # patreon post
|
||||
'748a976c6cedf7ea85b6f90e7cb685c7',
|
||||
'839796d7745e88ced6355504e1f74508',
|
||||
'bcdb740367d0f19f97a77e614b48a42d',
|
||||
'0f230b8c4e5d103d35a773fab9814ec3',
|
||||
'e5192d6cb4f84c4f4a658355310bf0f9',
|
||||
'91cbe172cd8ccbcf049fcea4204eb979',
|
||||
})
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_submission_id", "expected_hashes"),
|
||||
(
|
||||
(
|
||||
"m6lvrh",
|
||||
{
|
||||
"5c42b8341dd56eebef792e86f3981c6a",
|
||||
"8f38d76da46f4057bf2773a778e725ca",
|
||||
"f5776f8f90491c8b770b8e0a6bfa49b3",
|
||||
"fa1a43c94da30026ad19a9813a0ed2c2",
|
||||
},
|
||||
),
|
||||
(
|
||||
"ljyy27",
|
||||
{
|
||||
"359c203ec81d0bc00e675f1023673238",
|
||||
"79262fd46bce5bfa550d878a3b898be4",
|
||||
"808c35267f44acb523ce03bfa5687404",
|
||||
"ec8b65bdb7f1279c4b3af0ea2bbb30c3",
|
||||
},
|
||||
),
|
||||
(
|
||||
"obkflw",
|
||||
{
|
||||
"65163f685fb28c5b776e0e77122718be",
|
||||
"2a337eb5b13c34d3ca3f51b5db7c13e9",
|
||||
},
|
||||
),
|
||||
(
|
||||
"rb3ub6",
|
||||
{ # patreon post
|
||||
"748a976c6cedf7ea85b6f90e7cb685c7",
|
||||
"839796d7745e88ced6355504e1f74508",
|
||||
"bcdb740367d0f19f97a77e614b48a42d",
|
||||
"0f230b8c4e5d103d35a773fab9814ec3",
|
||||
"e5192d6cb4f84c4f4a658355310bf0f9",
|
||||
"91cbe172cd8ccbcf049fcea4204eb979",
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_gallery_download(test_submission_id: str, expected_hashes: set[str], reddit_instance: praw.Reddit):
|
||||
test_submission = reddit_instance.submission(id=test_submission_id)
|
||||
gallery = Gallery(test_submission)
|
||||
@@ -75,10 +99,13 @@ def test_gallery_download(test_submission_id: str, expected_hashes: set[str], re
|
||||
assert set(hashes) == expected_hashes
|
||||
|
||||
|
||||
@pytest.mark.parametrize('test_id', (
|
||||
'n0pyzp',
|
||||
'nxyahw',
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
"test_id",
|
||||
(
|
||||
"n0pyzp",
|
||||
"nxyahw",
|
||||
),
|
||||
)
|
||||
def test_gallery_download_raises_right_error(test_id: str, reddit_instance: praw.Reddit):
|
||||
test_submission = reddit_instance.submission(id=test_id)
|
||||
gallery = Gallery(test_submission)
|
||||
|
||||
@@ -10,20 +10,26 @@ from bdfr.site_downloaders.gfycat import Gfycat
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@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'),
|
||||
))
|
||||
@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)
|
||||
assert result.pop() == expected_url
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize(('test_url', 'expected_hash'), (
|
||||
('https://gfycat.com/definitivecaninecrayfish', '48f9bd4dbec1556d7838885612b13b39'),
|
||||
('https://gfycat.com/dazzlingsilkyiguana', '808941b48fc1e28713d36dd7ed9dc648'),
|
||||
))
|
||||
@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):
|
||||
mock_submission = Mock()
|
||||
mock_submission.url = test_url
|
||||
|
||||
@@ -11,166 +11,167 @@ from bdfr.site_downloaders.imgur import Imgur
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize(('test_url', 'expected_gen_dict', 'expected_image_dict'), (
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected_gen_dict", "expected_image_dict"),
|
||||
(
|
||||
'https://imgur.com/a/xWZsDDP',
|
||||
{'num_images': '1', 'id': 'xWZsDDP', 'hash': 'xWZsDDP'},
|
||||
[
|
||||
{'hash': 'ypa8YfS', 'title': '', 'ext': '.png', 'animated': False}
|
||||
]
|
||||
(
|
||||
"https://imgur.com/a/xWZsDDP",
|
||||
{"num_images": "1", "id": "xWZsDDP", "hash": "xWZsDDP"},
|
||||
[{"hash": "ypa8YfS", "title": "", "ext": ".png", "animated": False}],
|
||||
),
|
||||
(
|
||||
"https://imgur.com/gallery/IjJJdlC",
|
||||
{"num_images": 1, "id": 384898055, "hash": "IjJJdlC"},
|
||||
[
|
||||
{
|
||||
"hash": "CbbScDt",
|
||||
"description": "watch when he gets it",
|
||||
"ext": ".gif",
|
||||
"animated": True,
|
||||
"has_sound": False,
|
||||
}
|
||||
],
|
||||
),
|
||||
(
|
||||
"https://imgur.com/a/dcc84Gt",
|
||||
{"num_images": "4", "id": "dcc84Gt", "hash": "dcc84Gt"},
|
||||
[
|
||||
{"hash": "ylx0Kle", "ext": ".jpg", "title": ""},
|
||||
{"hash": "TdYfKbK", "ext": ".jpg", "title": ""},
|
||||
{"hash": "pCxGbe8", "ext": ".jpg", "title": ""},
|
||||
{"hash": "TSAkikk", "ext": ".jpg", "title": ""},
|
||||
],
|
||||
),
|
||||
(
|
||||
"https://m.imgur.com/a/py3RW0j",
|
||||
{
|
||||
"num_images": "1",
|
||||
"id": "py3RW0j",
|
||||
"hash": "py3RW0j",
|
||||
},
|
||||
[{"hash": "K24eQmK", "has_sound": False, "ext": ".jpg"}],
|
||||
),
|
||||
),
|
||||
(
|
||||
'https://imgur.com/gallery/IjJJdlC',
|
||||
{'num_images': 1, 'id': 384898055, 'hash': 'IjJJdlC'},
|
||||
[
|
||||
{'hash': 'CbbScDt',
|
||||
'description': 'watch when he gets it',
|
||||
'ext': '.gif',
|
||||
'animated': True,
|
||||
'has_sound': False
|
||||
}
|
||||
],
|
||||
),
|
||||
(
|
||||
'https://imgur.com/a/dcc84Gt',
|
||||
{'num_images': '4', 'id': 'dcc84Gt', 'hash': 'dcc84Gt'},
|
||||
[
|
||||
{'hash': 'ylx0Kle', 'ext': '.jpg', 'title': ''},
|
||||
{'hash': 'TdYfKbK', 'ext': '.jpg', 'title': ''},
|
||||
{'hash': 'pCxGbe8', 'ext': '.jpg', 'title': ''},
|
||||
{'hash': 'TSAkikk', 'ext': '.jpg', 'title': ''},
|
||||
]
|
||||
),
|
||||
(
|
||||
'https://m.imgur.com/a/py3RW0j',
|
||||
{'num_images': '1', 'id': 'py3RW0j', 'hash': 'py3RW0j', },
|
||||
[
|
||||
{'hash': 'K24eQmK', 'has_sound': False, 'ext': '.jpg'}
|
||||
],
|
||||
),
|
||||
))
|
||||
)
|
||||
def test_get_data_album(test_url: str, expected_gen_dict: dict, expected_image_dict: list[dict]):
|
||||
result = Imgur._get_data(test_url)
|
||||
assert all([result.get(key) == expected_gen_dict[key] for key in expected_gen_dict.keys()])
|
||||
|
||||
# Check if all the keys from the test dict are correct in at least one of the album entries
|
||||
assert any([all([image.get(key) == image_dict[key] for key in image_dict.keys()])
|
||||
for image_dict in expected_image_dict for image in result['album_images']['images']])
|
||||
assert any(
|
||||
[
|
||||
all([image.get(key) == image_dict[key] for key in image_dict.keys()])
|
||||
for image_dict in expected_image_dict
|
||||
for image in result["album_images"]["images"]
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize(('test_url', 'expected_image_dict'), (
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected_image_dict"),
|
||||
(
|
||||
'https://i.imgur.com/dLk3FGY.gifv',
|
||||
{'hash': 'dLk3FGY', 'title': '', 'ext': '.mp4', 'animated': True}
|
||||
("https://i.imgur.com/dLk3FGY.gifv", {"hash": "dLk3FGY", "title": "", "ext": ".mp4", "animated": True}),
|
||||
(
|
||||
"https://imgur.com/65FqTpT.gifv",
|
||||
{"hash": "65FqTpT", "title": "", "description": "", "animated": True, "mimetype": "video/mp4"},
|
||||
),
|
||||
),
|
||||
(
|
||||
'https://imgur.com/65FqTpT.gifv',
|
||||
{
|
||||
'hash': '65FqTpT',
|
||||
'title': '',
|
||||
'description': '',
|
||||
'animated': True,
|
||||
'mimetype': 'video/mp4'
|
||||
},
|
||||
),
|
||||
))
|
||||
)
|
||||
def test_get_data_gif(test_url: str, expected_image_dict: dict):
|
||||
result = Imgur._get_data(test_url)
|
||||
assert all([result.get(key) == expected_image_dict[key] for key in expected_image_dict.keys()])
|
||||
|
||||
|
||||
@pytest.mark.parametrize('test_extension', (
|
||||
'.gif',
|
||||
'.png',
|
||||
'.jpg',
|
||||
'.mp4'
|
||||
))
|
||||
@pytest.mark.parametrize("test_extension", (".gif", ".png", ".jpg", ".mp4"))
|
||||
def test_imgur_extension_validation_good(test_extension: str):
|
||||
result = Imgur._validate_extension(test_extension)
|
||||
assert result == test_extension
|
||||
|
||||
|
||||
@pytest.mark.parametrize('test_extension', (
|
||||
'.jpeg',
|
||||
'bad',
|
||||
'.avi',
|
||||
'.test',
|
||||
'.flac',
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
"test_extension",
|
||||
(
|
||||
".jpeg",
|
||||
"bad",
|
||||
".avi",
|
||||
".test",
|
||||
".flac",
|
||||
),
|
||||
)
|
||||
def test_imgur_extension_validation_bad(test_extension: str):
|
||||
with pytest.raises(SiteDownloaderError):
|
||||
Imgur._validate_extension(test_extension)
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize(('test_url', 'expected_hashes'), (
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected_hashes"),
|
||||
(
|
||||
'https://imgur.com/a/xWZsDDP',
|
||||
('f551d6e6b0fef2ce909767338612e31b',)
|
||||
),
|
||||
(
|
||||
'https://imgur.com/gallery/IjJJdlC',
|
||||
('740b006cf9ec9d6f734b6e8f5130bdab',),
|
||||
),
|
||||
(
|
||||
'https://imgur.com/a/dcc84Gt',
|
||||
("https://imgur.com/a/xWZsDDP", ("f551d6e6b0fef2ce909767338612e31b",)),
|
||||
(
|
||||
'cf1158e1de5c3c8993461383b96610cf',
|
||||
'28d6b791a2daef8aa363bf5a3198535d',
|
||||
'248ef8f2a6d03eeb2a80d0123dbaf9b6',
|
||||
'029c475ce01b58fdf1269d8771d33913',
|
||||
"https://imgur.com/gallery/IjJJdlC",
|
||||
("740b006cf9ec9d6f734b6e8f5130bdab",),
|
||||
),
|
||||
(
|
||||
"https://imgur.com/a/dcc84Gt",
|
||||
(
|
||||
"cf1158e1de5c3c8993461383b96610cf",
|
||||
"28d6b791a2daef8aa363bf5a3198535d",
|
||||
"248ef8f2a6d03eeb2a80d0123dbaf9b6",
|
||||
"029c475ce01b58fdf1269d8771d33913",
|
||||
),
|
||||
),
|
||||
(
|
||||
"https://imgur.com/a/eemHCCK",
|
||||
(
|
||||
"9cb757fd8f055e7ef7aa88addc9d9fa5",
|
||||
"b6cb6c918e2544e96fb7c07d828774b5",
|
||||
"fb6c913d721c0bbb96aa65d7f560d385",
|
||||
),
|
||||
),
|
||||
(
|
||||
"https://i.imgur.com/lFJai6i.gifv",
|
||||
("01a6e79a30bec0e644e5da12365d5071",),
|
||||
),
|
||||
(
|
||||
"https://i.imgur.com/ywSyILa.gifv?",
|
||||
("56d4afc32d2966017c38d98568709b45",),
|
||||
),
|
||||
(
|
||||
"https://imgur.com/ubYwpbk.GIFV",
|
||||
("d4a774aac1667783f9ed3a1bd02fac0c",),
|
||||
),
|
||||
(
|
||||
"https://i.imgur.com/j1CNCZY.gifv",
|
||||
("58e7e6d972058c18b7ecde910ca147e3",),
|
||||
),
|
||||
(
|
||||
"https://i.imgur.com/uTvtQsw.gifv",
|
||||
("46c86533aa60fc0e09f2a758513e3ac2",),
|
||||
),
|
||||
(
|
||||
"https://i.imgur.com/OGeVuAe.giff",
|
||||
("77389679084d381336f168538793f218",),
|
||||
),
|
||||
(
|
||||
"https://i.imgur.com/OGeVuAe.gift",
|
||||
("77389679084d381336f168538793f218",),
|
||||
),
|
||||
(
|
||||
"https://i.imgur.com/3SKrQfK.jpg?1",
|
||||
("aa299e181b268578979cad176d1bd1d0",),
|
||||
),
|
||||
(
|
||||
"https://i.imgur.com/cbivYRW.jpg?3",
|
||||
("7ec6ceef5380cb163a1d498c359c51fd",),
|
||||
),
|
||||
(
|
||||
"http://i.imgur.com/s9uXxlq.jpg?5.jpg",
|
||||
("338de3c23ee21af056b3a7c154e2478f",),
|
||||
),
|
||||
),
|
||||
(
|
||||
'https://imgur.com/a/eemHCCK',
|
||||
(
|
||||
'9cb757fd8f055e7ef7aa88addc9d9fa5',
|
||||
'b6cb6c918e2544e96fb7c07d828774b5',
|
||||
'fb6c913d721c0bbb96aa65d7f560d385',
|
||||
),
|
||||
),
|
||||
(
|
||||
'https://i.imgur.com/lFJai6i.gifv',
|
||||
('01a6e79a30bec0e644e5da12365d5071',),
|
||||
),
|
||||
(
|
||||
'https://i.imgur.com/ywSyILa.gifv?',
|
||||
('56d4afc32d2966017c38d98568709b45',),
|
||||
),
|
||||
(
|
||||
'https://imgur.com/ubYwpbk.GIFV',
|
||||
('d4a774aac1667783f9ed3a1bd02fac0c',),
|
||||
),
|
||||
(
|
||||
'https://i.imgur.com/j1CNCZY.gifv',
|
||||
('58e7e6d972058c18b7ecde910ca147e3',),
|
||||
),
|
||||
(
|
||||
'https://i.imgur.com/uTvtQsw.gifv',
|
||||
('46c86533aa60fc0e09f2a758513e3ac2',),
|
||||
),
|
||||
(
|
||||
'https://i.imgur.com/OGeVuAe.giff',
|
||||
('77389679084d381336f168538793f218',),
|
||||
),
|
||||
(
|
||||
'https://i.imgur.com/OGeVuAe.gift',
|
||||
('77389679084d381336f168538793f218',),
|
||||
),
|
||||
(
|
||||
'https://i.imgur.com/3SKrQfK.jpg?1',
|
||||
('aa299e181b268578979cad176d1bd1d0',),
|
||||
),
|
||||
(
|
||||
'https://i.imgur.com/cbivYRW.jpg?3',
|
||||
('7ec6ceef5380cb163a1d498c359c51fd',),
|
||||
),
|
||||
(
|
||||
'http://i.imgur.com/s9uXxlq.jpg?5.jpg',
|
||||
('338de3c23ee21af056b3a7c154e2478f',),
|
||||
),
|
||||
))
|
||||
)
|
||||
def test_find_resources(test_url: str, expected_hashes: list[str]):
|
||||
mock_download = Mock()
|
||||
mock_download.url = test_url
|
||||
|
||||
@@ -12,9 +12,10 @@ from bdfr.site_downloaders.pornhub import PornHub
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.parametrize(('test_url', 'expected_hash'), (
|
||||
('https://www.pornhub.com/view_video.php?viewkey=ph6074c59798497', 'ad52a0f4fce8f99df0abed17de1d04c7'),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected_hash"),
|
||||
(("https://www.pornhub.com/view_video.php?viewkey=ph6074c59798497", "ad52a0f4fce8f99df0abed17de1d04c7"),),
|
||||
)
|
||||
def test_hash_resources_good(test_url: str, expected_hash: str):
|
||||
test_submission = MagicMock()
|
||||
test_submission.url = test_url
|
||||
@@ -27,9 +28,7 @@ def test_hash_resources_good(test_url: str, expected_hash: str):
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize('test_url', (
|
||||
'https://www.pornhub.com/view_video.php?viewkey=ph5ede121f0d3f8',
|
||||
))
|
||||
@pytest.mark.parametrize("test_url", ("https://www.pornhub.com/view_video.php?viewkey=ph5ede121f0d3f8",))
|
||||
def test_find_resources_good(test_url: str):
|
||||
test_submission = MagicMock()
|
||||
test_submission.url = test_url
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# coding=utf-8
|
||||
|
||||
from unittest.mock import Mock
|
||||
import re
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -11,45 +11,55 @@ from bdfr.site_downloaders.redgifs import Redgifs
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize(('test_url', 'expected'), (
|
||||
('https://redgifs.com/watch/frighteningvictorioussalamander',
|
||||
{'FrighteningVictoriousSalamander.mp4'}),
|
||||
('https://redgifs.com/watch/springgreendecisivetaruca',
|
||||
{'SpringgreenDecisiveTaruca.mp4'}),
|
||||
('https://www.redgifs.com/watch/palegoldenrodrawhalibut',
|
||||
{'PalegoldenrodRawHalibut.mp4'}),
|
||||
('https://redgifs.com/watch/hollowintentsnowyowl',
|
||||
{'HollowIntentSnowyowl-large.jpg'}),
|
||||
('https://www.redgifs.com/watch/lustrousstickywaxwing',
|
||||
{'EntireEnchantingHypsilophodon-large.jpg',
|
||||
'FancyMagnificentAdamsstaghornedbeetle-large.jpg',
|
||||
'LustrousStickyWaxwing-large.jpg',
|
||||
'ParchedWindyArmyworm-large.jpg',
|
||||
'ThunderousColorlessErmine-large.jpg',
|
||||
'UnripeUnkemptWoodpecker-large.jpg'}),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected"),
|
||||
(
|
||||
("https://redgifs.com/watch/frighteningvictorioussalamander", {"FrighteningVictoriousSalamander.mp4"}),
|
||||
("https://redgifs.com/watch/springgreendecisivetaruca", {"SpringgreenDecisiveTaruca.mp4"}),
|
||||
("https://www.redgifs.com/watch/palegoldenrodrawhalibut", {"PalegoldenrodRawHalibut.mp4"}),
|
||||
("https://redgifs.com/watch/hollowintentsnowyowl", {"HollowIntentSnowyowl-large.jpg"}),
|
||||
(
|
||||
"https://www.redgifs.com/watch/lustrousstickywaxwing",
|
||||
{
|
||||
"EntireEnchantingHypsilophodon-large.jpg",
|
||||
"FancyMagnificentAdamsstaghornedbeetle-large.jpg",
|
||||
"LustrousStickyWaxwing-large.jpg",
|
||||
"ParchedWindyArmyworm-large.jpg",
|
||||
"ThunderousColorlessErmine-large.jpg",
|
||||
"UnripeUnkemptWoodpecker-large.jpg",
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_get_link(test_url: str, expected: set[str]):
|
||||
result = Redgifs._get_link(test_url)
|
||||
result = list(result)
|
||||
patterns = [r'https://thumbs\d\.redgifs\.com/' + e + r'.*' for e in expected]
|
||||
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.parametrize(('test_url', 'expected_hashes'), (
|
||||
('https://redgifs.com/watch/frighteningvictorioussalamander', {'4007c35d9e1f4b67091b5f12cffda00a'}),
|
||||
('https://redgifs.com/watch/springgreendecisivetaruca', {'8dac487ac49a1f18cc1b4dabe23f0869'}),
|
||||
('https://redgifs.com/watch/leafysaltydungbeetle', {'076792c660b9c024c0471ef4759af8bd'}),
|
||||
('https://www.redgifs.com/watch/palegoldenrodrawhalibut', {'46d5aa77fe80c6407de1ecc92801c10e'}),
|
||||
('https://redgifs.com/watch/hollowintentsnowyowl', {'5ee51fa15e0a58e98f11dea6a6cca771'}),
|
||||
('https://www.redgifs.com/watch/lustrousstickywaxwing',
|
||||
{'b461e55664f07bed8d2f41d8586728fa',
|
||||
'30ba079a8ed7d7adf17929dc3064c10f',
|
||||
'0d4f149d170d29fc2f015c1121bab18b',
|
||||
'53987d99cfd77fd65b5fdade3718f9f1',
|
||||
'fb2e7d972846b83bf4016447d3060d60',
|
||||
'44fb28f72ec9a5cca63fa4369ab4f672'}),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected_hashes"),
|
||||
(
|
||||
("https://redgifs.com/watch/frighteningvictorioussalamander", {"4007c35d9e1f4b67091b5f12cffda00a"}),
|
||||
("https://redgifs.com/watch/springgreendecisivetaruca", {"8dac487ac49a1f18cc1b4dabe23f0869"}),
|
||||
("https://redgifs.com/watch/leafysaltydungbeetle", {"076792c660b9c024c0471ef4759af8bd"}),
|
||||
("https://www.redgifs.com/watch/palegoldenrodrawhalibut", {"46d5aa77fe80c6407de1ecc92801c10e"}),
|
||||
("https://redgifs.com/watch/hollowintentsnowyowl", {"5ee51fa15e0a58e98f11dea6a6cca771"}),
|
||||
(
|
||||
"https://www.redgifs.com/watch/lustrousstickywaxwing",
|
||||
{
|
||||
"b461e55664f07bed8d2f41d8586728fa",
|
||||
"30ba079a8ed7d7adf17929dc3064c10f",
|
||||
"0d4f149d170d29fc2f015c1121bab18b",
|
||||
"53987d99cfd77fd65b5fdade3718f9f1",
|
||||
"fb2e7d972846b83bf4016447d3060d60",
|
||||
"44fb28f72ec9a5cca63fa4369ab4f672",
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_download_resource(test_url: str, expected_hashes: set[str]):
|
||||
mock_submission = Mock()
|
||||
mock_submission.url = test_url
|
||||
@@ -62,18 +72,30 @@ def test_download_resource(test_url: str, expected_hashes: set[str]):
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize(('test_url', 'expected_link', 'expected_hash'), (
|
||||
('https://redgifs.com/watch/flippantmemorablebaiji', {'FlippantMemorableBaiji-mobile.mp4'},
|
||||
{'41a5fb4865367ede9f65fc78736f497a'}),
|
||||
('https://redgifs.com/watch/thirstyunfortunatewaterdragons', {'thirstyunfortunatewaterdragons-mobile.mp4'},
|
||||
{'1a51dad8fedb594bdd84f027b3cbe8af'}),
|
||||
('https://redgifs.com/watch/conventionalplainxenopterygii', {'conventionalplainxenopterygii-mobile.mp4'},
|
||||
{'2e1786b3337da85b80b050e2c289daa4'})
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected_link", "expected_hash"),
|
||||
(
|
||||
(
|
||||
"https://redgifs.com/watch/flippantmemorablebaiji",
|
||||
{"FlippantMemorableBaiji-mobile.mp4"},
|
||||
{"41a5fb4865367ede9f65fc78736f497a"},
|
||||
),
|
||||
(
|
||||
"https://redgifs.com/watch/thirstyunfortunatewaterdragons",
|
||||
{"thirstyunfortunatewaterdragons-mobile.mp4"},
|
||||
{"1a51dad8fedb594bdd84f027b3cbe8af"},
|
||||
),
|
||||
(
|
||||
"https://redgifs.com/watch/conventionalplainxenopterygii",
|
||||
{"conventionalplainxenopterygii-mobile.mp4"},
|
||||
{"2e1786b3337da85b80b050e2c289daa4"},
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_hd_soft_fail(test_url: str, expected_link: set[str], expected_hash: set[str]):
|
||||
link = Redgifs._get_link(test_url)
|
||||
link = list(link)
|
||||
patterns = [r'https://thumbs\d\.redgifs\.com/' + e + r'.*' for e in expected_link]
|
||||
patterns = [r"https://thumbs\d\.redgifs\.com/" + e + r".*" for e in expected_link]
|
||||
assert all([re.match(p, r) for p in patterns] for r in link)
|
||||
mock_submission = Mock()
|
||||
mock_submission.url = test_url
|
||||
|
||||
@@ -10,11 +10,14 @@ from bdfr.site_downloaders.self_post import SelfPost
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.reddit
|
||||
@pytest.mark.parametrize(('test_submission_id', 'expected_hash'), (
|
||||
('ltmivt', '7d2c9e4e989e5cf2dca2e55a06b1c4f6'),
|
||||
('ltoaan', '221606386b614d6780c2585a59bd333f'),
|
||||
('d3sc8o', 'c1ff2b6bd3f6b91381dcd18dfc4ca35f'),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_submission_id", "expected_hash"),
|
||||
(
|
||||
("ltmivt", "7d2c9e4e989e5cf2dca2e55a06b1c4f6"),
|
||||
("ltoaan", "221606386b614d6780c2585a59bd333f"),
|
||||
("d3sc8o", "c1ff2b6bd3f6b91381dcd18dfc4ca35f"),
|
||||
),
|
||||
)
|
||||
def test_find_resource(test_submission_id: str, expected_hash: str, reddit_instance: praw.Reddit):
|
||||
submission = reddit_instance.submission(id=test_submission_id)
|
||||
downloader = SelfPost(submission)
|
||||
|
||||
@@ -8,55 +8,83 @@ from bdfr.resource import Resource
|
||||
from bdfr.site_downloaders.vidble import Vidble
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('test_url', 'expected'), (
|
||||
('/RDFbznUvcN_med.jpg', '/RDFbznUvcN.jpg'),
|
||||
))
|
||||
@pytest.mark.parametrize(("test_url", "expected"), (("/RDFbznUvcN_med.jpg", "/RDFbznUvcN.jpg"),))
|
||||
def test_change_med_url(test_url: str, expected: str):
|
||||
result = Vidble.change_med_url(test_url)
|
||||
assert result == expected
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize(('test_url', 'expected'), (
|
||||
('https://www.vidble.com/show/UxsvAssYe5', {
|
||||
'https://www.vidble.com/UxsvAssYe5.gif',
|
||||
}),
|
||||
('https://vidble.com/show/RDFbznUvcN', {
|
||||
'https://www.vidble.com/RDFbznUvcN.jpg',
|
||||
}),
|
||||
('https://vidble.com/album/h0jTLs6B', {
|
||||
'https://www.vidble.com/XG4eAoJ5JZ.jpg',
|
||||
'https://www.vidble.com/IqF5UdH6Uq.jpg',
|
||||
'https://www.vidble.com/VWuNsnLJMD.jpg',
|
||||
'https://www.vidble.com/sMmM8O650W.jpg',
|
||||
}),
|
||||
('https://www.vidble.com/pHuwWkOcEb', {
|
||||
'https://www.vidble.com/pHuwWkOcEb.jpg',
|
||||
}),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected"),
|
||||
(
|
||||
(
|
||||
"https://www.vidble.com/show/UxsvAssYe5",
|
||||
{
|
||||
"https://www.vidble.com/UxsvAssYe5.gif",
|
||||
},
|
||||
),
|
||||
(
|
||||
"https://vidble.com/show/RDFbznUvcN",
|
||||
{
|
||||
"https://www.vidble.com/RDFbznUvcN.jpg",
|
||||
},
|
||||
),
|
||||
(
|
||||
"https://vidble.com/album/h0jTLs6B",
|
||||
{
|
||||
"https://www.vidble.com/XG4eAoJ5JZ.jpg",
|
||||
"https://www.vidble.com/IqF5UdH6Uq.jpg",
|
||||
"https://www.vidble.com/VWuNsnLJMD.jpg",
|
||||
"https://www.vidble.com/sMmM8O650W.jpg",
|
||||
},
|
||||
),
|
||||
(
|
||||
"https://www.vidble.com/pHuwWkOcEb",
|
||||
{
|
||||
"https://www.vidble.com/pHuwWkOcEb.jpg",
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_get_links(test_url: str, expected: set[str]):
|
||||
results = Vidble.get_links(test_url)
|
||||
assert results == expected
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize(('test_url', 'expected_hashes'), (
|
||||
('https://www.vidble.com/show/UxsvAssYe5', {
|
||||
'0ef2f8e0e0b45936d2fb3e6fbdf67e28',
|
||||
}),
|
||||
('https://vidble.com/show/RDFbznUvcN', {
|
||||
'c2dd30a71e32369c50eed86f86efff58',
|
||||
}),
|
||||
('https://vidble.com/album/h0jTLs6B', {
|
||||
'3b3cba02e01c91f9858a95240b942c71',
|
||||
'dd6ecf5fc9e936f9fb614eb6a0537f99',
|
||||
'b31a942cd8cdda218ed547bbc04c3a27',
|
||||
'6f77c570b451eef4222804bd52267481',
|
||||
}),
|
||||
('https://www.vidble.com/pHuwWkOcEb', {
|
||||
'585f486dd0b2f23a57bddbd5bf185bc7',
|
||||
}),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected_hashes"),
|
||||
(
|
||||
(
|
||||
"https://www.vidble.com/show/UxsvAssYe5",
|
||||
{
|
||||
"0ef2f8e0e0b45936d2fb3e6fbdf67e28",
|
||||
},
|
||||
),
|
||||
(
|
||||
"https://vidble.com/show/RDFbznUvcN",
|
||||
{
|
||||
"c2dd30a71e32369c50eed86f86efff58",
|
||||
},
|
||||
),
|
||||
(
|
||||
"https://vidble.com/album/h0jTLs6B",
|
||||
{
|
||||
"3b3cba02e01c91f9858a95240b942c71",
|
||||
"dd6ecf5fc9e936f9fb614eb6a0537f99",
|
||||
"b31a942cd8cdda218ed547bbc04c3a27",
|
||||
"6f77c570b451eef4222804bd52267481",
|
||||
},
|
||||
),
|
||||
(
|
||||
"https://www.vidble.com/pHuwWkOcEb",
|
||||
{
|
||||
"585f486dd0b2f23a57bddbd5bf185bc7",
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_find_resources(test_url: str, expected_hashes: set[str]):
|
||||
mock_download = Mock()
|
||||
mock_download.url = test_url
|
||||
|
||||
@@ -12,9 +12,10 @@ from bdfr.site_downloaders.vreddit import VReddit
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.parametrize(('test_url', 'expected_hash'), (
|
||||
('https://reddit.com/r/Unexpected/comments/z4xsuj/omg_thats_so_cute/', '1ffab5e5c0cc96db18108e4f37e8ca7f'),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected_hash"),
|
||||
(("https://reddit.com/r/Unexpected/comments/z4xsuj/omg_thats_so_cute/", "1ffab5e5c0cc96db18108e4f37e8ca7f"),),
|
||||
)
|
||||
def test_find_resources_good(test_url: str, expected_hash: str):
|
||||
test_submission = MagicMock()
|
||||
test_submission.url = test_url
|
||||
@@ -27,10 +28,13 @@ def test_find_resources_good(test_url: str, expected_hash: str):
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize('test_url', (
|
||||
'https://www.polygon.com/disney-plus/2020/5/14/21249881/gargoyles-animated-series-disney-plus-greg-weisman'
|
||||
'-interview-oj-simpson-goliath-chronicles',
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
"test_url",
|
||||
(
|
||||
"https://www.polygon.com/disney-plus/2020/5/14/21249881/gargoyles-animated-series-disney-plus-greg-weisman"
|
||||
"-interview-oj-simpson-goliath-chronicles",
|
||||
),
|
||||
)
|
||||
def test_find_resources_bad(test_url: str):
|
||||
test_submission = MagicMock()
|
||||
test_submission.url = test_url
|
||||
|
||||
@@ -12,10 +12,13 @@ from bdfr.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', '2d60b54582df5b95ec72bb00b580d2ff'),
|
||||
('https://www.youtube.com/watch?v=GcI7nxQj7HA', '5db0fc92a0a7fb9ac91e63505eea9cf0'),
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
("test_url", "expected_hash"),
|
||||
(
|
||||
("https://www.youtube.com/watch?v=uSm2VDgRIUs", "2d60b54582df5b95ec72bb00b580d2ff"),
|
||||
("https://www.youtube.com/watch?v=GcI7nxQj7HA", "5db0fc92a0a7fb9ac91e63505eea9cf0"),
|
||||
),
|
||||
)
|
||||
def test_find_resources_good(test_url: str, expected_hash: str):
|
||||
test_submission = MagicMock()
|
||||
test_submission.url = test_url
|
||||
@@ -28,10 +31,13 @@ def test_find_resources_good(test_url: str, expected_hash: str):
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.parametrize('test_url', (
|
||||
'https://www.polygon.com/disney-plus/2020/5/14/21249881/gargoyles-animated-series-disney-plus-greg-weisman'
|
||||
'-interview-oj-simpson-goliath-chronicles',
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
"test_url",
|
||||
(
|
||||
"https://www.polygon.com/disney-plus/2020/5/14/21249881/gargoyles-animated-series-disney-plus-greg-weisman"
|
||||
"-interview-oj-simpson-goliath-chronicles",
|
||||
),
|
||||
)
|
||||
def test_find_resources_bad(test_url: str):
|
||||
test_submission = MagicMock()
|
||||
test_submission.url = test_url
|
||||
|
||||
Reference in New Issue
Block a user