mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
[tests] skip tests requiring auth when non is provided
This commit is contained in:
parent
355b909f46
commit
69726fc82c
@ -9,11 +9,18 @@ from gallery_dl.extractor import kemonoparty
|
||||
|
||||
__tests__ = (
|
||||
{
|
||||
"#url" : "https://coomer.party/onlyfans/user/alinity/post/125962203",
|
||||
"#comment" : "coomer.party (#2100)",
|
||||
"#url" : "https://coomer.su/onlyfans/user/alinity/post/125962203",
|
||||
"#comment" : "coomer (#2100)",
|
||||
"#category": ("", "coomerparty", "onlyfans"),
|
||||
"#class" : kemonoparty.KemonopartyPostExtractor,
|
||||
"#pattern" : r"https://coomer\.party/data/7d/3f/7d3fd9804583dc224968c0591163ec91794552b04f00a6c2f42a15b68231d5a8\.jpg",
|
||||
"#urls" : "https://coomer.su/data/7d/3f/7d3fd9804583dc224968c0591163ec91794552b04f00a6c2f42a15b68231d5a8.jpg",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://coomer.party/onlyfans/user/alinity/post/125962203",
|
||||
"#category": ("", "coomerparty", "onlyfans"),
|
||||
"#class" : kemonoparty.KemonopartyPostExtractor,
|
||||
"#urls" : "https://coomer.party/data/7d/3f/7d3fd9804583dc224968c0591163ec91794552b04f00a6c2f42a15b68231d5a8.jpg",
|
||||
},
|
||||
|
||||
)
|
||||
|
@ -297,6 +297,7 @@ __tests__ = (
|
||||
"#category": ("", "kemonoparty", "favorite"),
|
||||
"#class" : kemonoparty.KemonopartyFavoriteExtractor,
|
||||
"#pattern" : kemonoparty.KemonopartyUserExtractor.pattern,
|
||||
"#auth" : True,
|
||||
"#count" : 3,
|
||||
"#sha1_url": "f4b5b796979bcba824af84206578c79101c7f0e1",
|
||||
},
|
||||
@ -306,6 +307,7 @@ __tests__ = (
|
||||
"#category": ("", "kemonoparty", "favorite"),
|
||||
"#class" : kemonoparty.KemonopartyFavoriteExtractor,
|
||||
"#pattern" : kemonoparty.KemonopartyPostExtractor.pattern,
|
||||
"#auth" : True,
|
||||
"#count" : 3,
|
||||
"#sha1_url": "ecfccf5f0d50b8d14caa7bbdcf071de5c1e5b90f",
|
||||
},
|
||||
@ -315,6 +317,7 @@ __tests__ = (
|
||||
"#category": ("", "kemonoparty", "favorite"),
|
||||
"#class" : kemonoparty.KemonopartyFavoriteExtractor,
|
||||
"#pattern" : kemonoparty.KemonopartyPostExtractor.pattern,
|
||||
"#auth" : True,
|
||||
"#count" : 3,
|
||||
"#sha1_url": "4be8e84cb384a907a8e7997baaf6287b451783b5",
|
||||
},
|
||||
|
@ -38,6 +38,15 @@ CONFIG = {
|
||||
},
|
||||
}
|
||||
|
||||
AUTH = {
|
||||
"pixiv",
|
||||
"nijie",
|
||||
"horne",
|
||||
"seiga",
|
||||
"instagram",
|
||||
"twitter",
|
||||
}
|
||||
|
||||
|
||||
class TestExtractorResults(unittest.TestCase):
|
||||
|
||||
@ -76,6 +85,18 @@ class TestExtractorResults(unittest.TestCase):
|
||||
for key, value in result["#options"].items():
|
||||
key = key.split(".")
|
||||
config.set(key[:-1], key[-1], value)
|
||||
|
||||
requires_auth = result.get("#auth")
|
||||
if requires_auth is None:
|
||||
requires_auth = (result["#category"][1] in AUTH)
|
||||
if requires_auth:
|
||||
extr = result["#class"].from_url(result["#url"])
|
||||
if not any(extr.config(key) for key in (
|
||||
"username", "cookies", "api-key", "client-id")):
|
||||
msg = "no auth"
|
||||
self._skipped.append((result["#url"], msg))
|
||||
self.skipTest(msg)
|
||||
|
||||
if "#range" in result:
|
||||
config.set((), "image-range" , result["#range"])
|
||||
config.set((), "chapter-range", result["#range"])
|
||||
@ -371,7 +392,7 @@ def load_test_config():
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except Exception as exc:
|
||||
print("Error when loading {}: {}: {}".format(
|
||||
sys.exit("Error when loading {}: {}: {}".format(
|
||||
path, exc.__class__.__name__, exc))
|
||||
|
||||
|
||||
@ -422,7 +443,7 @@ def generate_tests():
|
||||
setattr(TestExtractorResults, method.__name__, method)
|
||||
|
||||
|
||||
load_test_config()
|
||||
generate_tests()
|
||||
if __name__ == "__main__":
|
||||
load_test_config()
|
||||
unittest.main(warnings="ignore")
|
||||
|
Loading…
Reference in New Issue
Block a user