1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

[tests] skip tests requiring auth when non is provided

This commit is contained in:
Mike Fährmann 2024-01-14 22:09:26 +01:00
parent 355b909f46
commit 69726fc82c
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 36 additions and 5 deletions

View File

@ -9,11 +9,18 @@ from gallery_dl.extractor import kemonoparty
__tests__ = ( __tests__ = (
{ {
"#url" : "https://coomer.party/onlyfans/user/alinity/post/125962203", "#url" : "https://coomer.su/onlyfans/user/alinity/post/125962203",
"#comment" : "coomer.party (#2100)", "#comment" : "coomer (#2100)",
"#category": ("", "coomerparty", "onlyfans"), "#category": ("", "coomerparty", "onlyfans"),
"#class" : kemonoparty.KemonopartyPostExtractor, "#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",
}, },
) )

View File

@ -297,6 +297,7 @@ __tests__ = (
"#category": ("", "kemonoparty", "favorite"), "#category": ("", "kemonoparty", "favorite"),
"#class" : kemonoparty.KemonopartyFavoriteExtractor, "#class" : kemonoparty.KemonopartyFavoriteExtractor,
"#pattern" : kemonoparty.KemonopartyUserExtractor.pattern, "#pattern" : kemonoparty.KemonopartyUserExtractor.pattern,
"#auth" : True,
"#count" : 3, "#count" : 3,
"#sha1_url": "f4b5b796979bcba824af84206578c79101c7f0e1", "#sha1_url": "f4b5b796979bcba824af84206578c79101c7f0e1",
}, },
@ -306,6 +307,7 @@ __tests__ = (
"#category": ("", "kemonoparty", "favorite"), "#category": ("", "kemonoparty", "favorite"),
"#class" : kemonoparty.KemonopartyFavoriteExtractor, "#class" : kemonoparty.KemonopartyFavoriteExtractor,
"#pattern" : kemonoparty.KemonopartyPostExtractor.pattern, "#pattern" : kemonoparty.KemonopartyPostExtractor.pattern,
"#auth" : True,
"#count" : 3, "#count" : 3,
"#sha1_url": "ecfccf5f0d50b8d14caa7bbdcf071de5c1e5b90f", "#sha1_url": "ecfccf5f0d50b8d14caa7bbdcf071de5c1e5b90f",
}, },
@ -315,6 +317,7 @@ __tests__ = (
"#category": ("", "kemonoparty", "favorite"), "#category": ("", "kemonoparty", "favorite"),
"#class" : kemonoparty.KemonopartyFavoriteExtractor, "#class" : kemonoparty.KemonopartyFavoriteExtractor,
"#pattern" : kemonoparty.KemonopartyPostExtractor.pattern, "#pattern" : kemonoparty.KemonopartyPostExtractor.pattern,
"#auth" : True,
"#count" : 3, "#count" : 3,
"#sha1_url": "4be8e84cb384a907a8e7997baaf6287b451783b5", "#sha1_url": "4be8e84cb384a907a8e7997baaf6287b451783b5",
}, },

View File

@ -38,6 +38,15 @@ CONFIG = {
}, },
} }
AUTH = {
"pixiv",
"nijie",
"horne",
"seiga",
"instagram",
"twitter",
}
class TestExtractorResults(unittest.TestCase): class TestExtractorResults(unittest.TestCase):
@ -76,6 +85,18 @@ class TestExtractorResults(unittest.TestCase):
for key, value in result["#options"].items(): for key, value in result["#options"].items():
key = key.split(".") key = key.split(".")
config.set(key[:-1], key[-1], value) 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: if "#range" in result:
config.set((), "image-range" , result["#range"]) config.set((), "image-range" , result["#range"])
config.set((), "chapter-range", result["#range"]) config.set((), "chapter-range", result["#range"])
@ -371,7 +392,7 @@ def load_test_config():
except FileNotFoundError: except FileNotFoundError:
pass pass
except Exception as exc: except Exception as exc:
print("Error when loading {}: {}: {}".format( sys.exit("Error when loading {}: {}: {}".format(
path, exc.__class__.__name__, exc)) path, exc.__class__.__name__, exc))
@ -422,7 +443,7 @@ def generate_tests():
setattr(TestExtractorResults, method.__name__, method) setattr(TestExtractorResults, method.__name__, method)
load_test_config()
generate_tests() generate_tests()
if __name__ == "__main__": if __name__ == "__main__":
load_test_config()
unittest.main(warnings="ignore") unittest.main(warnings="ignore")