1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 04:02:32 +01:00

[tests] support one regex per URL for #pattern

This commit is contained in:
Mike Fährmann 2023-09-28 21:56:09 +02:00
parent be17103e21
commit bd3f7a5bbc
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 25 additions and 4 deletions

View File

@ -9,15 +9,31 @@ from gallery_dl.extractor import redgifs
__tests__ = (
{
"#url" : "https://www.redgifs.com/users/Natalifiction",
"#url" : "https://www.redgifs.com/users/mmj",
"#category": ("", "redgifs", "user"),
"#class" : redgifs.RedgifsUserExtractor,
"#pattern" : r"https://\w+\.redgifs\.com/[\w-]+\.mp4",
"#count" : ">= 100",
"#count" : range(50, 60),
},
{
"#url" : "https://www.redgifs.com/users/mmj?order=old",
"#comment" : "'order' URL parameter (#4583)",
"#category": ("", "redgifs", "user"),
"#class" : redgifs.RedgifsUserExtractor,
"#range" : "1-5",
"#patterns": (
r"https://thumbs\d+\.redgifs\.com/ShoddyOilyHarlequinbug\.mp4",
r"https://thumbs\d+\.redgifs\.com/UnevenPrestigiousKilldeer\.mp4",
r"https://thumbs\d+\.redgifs\.com/EveryShockingFlickertailsquirrel\.mp4",
r"https://thumbs\d+\.redgifs\.com/NegativeWarlikeAmericancurl\.mp4",
r"https://thumbs\d+\.redgifs\.com/PopularTerribleFritillarybutterfly\.mp4",
),
},
{
"#url" : "https://v3.redgifs.com/users/lamsinka89",
"#comment" : "'v3' subdomain (#3588, #3589)",
"#category": ("", "redgifs", "user"),
"#class" : redgifs.RedgifsUserExtractor,
"#pattern" : r"https://\w+\.redgifs\.com/[\w-]+\.(mp4|jpg)",

View File

@ -148,8 +148,13 @@ class TestExtractorResults(unittest.TestCase):
if "#pattern" in result:
self.assertGreater(len(tjob.url_list), 0)
for url in tjob.url_list:
self.assertRegex(url, result["#pattern"])
pattern = result["#pattern"]
if isinstance(pattern, str):
for url in tjob.url_list:
self.assertRegex(url, pattern, msg="#pattern")
else:
for url, pat in zip(tjob.url_list, pattern):
self.assertRegex(url, pat, msg="#pattern")
if "#urls" in result:
expected = result["#urls"]