Skip to content

Commit

Permalink
[tests] skip tests requiring auth when non is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jan 14, 2024
1 parent 355b909 commit 69726fc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
11 changes: 9 additions & 2 deletions test/results/coomerparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@


__tests__ = (
{
"#url" : "https://coomer.su/onlyfans/user/alinity/post/125962203",
"#comment" : "coomer (#2100)",
"#category": ("", "coomerparty", "onlyfans"),
"#class" : kemonoparty.KemonopartyPostExtractor,
"#urls" : "https://coomer.su/data/7d/3f/7d3fd9804583dc224968c0591163ec91794552b04f00a6c2f42a15b68231d5a8.jpg",
},

{
"#url" : "https://coomer.party/onlyfans/user/alinity/post/125962203",
"#comment" : "coomer.party (#2100)",
"#category": ("", "coomerparty", "onlyfans"),
"#class" : kemonoparty.KemonopartyPostExtractor,
"#pattern" : r"https://coomer\.party/data/7d/3f/7d3fd9804583dc224968c0591163ec91794552b04f00a6c2f42a15b68231d5a8\.jpg",
"#urls" : "https://coomer.party/data/7d/3f/7d3fd9804583dc224968c0591163ec91794552b04f00a6c2f42a15b68231d5a8.jpg",
},

)
3 changes: 3 additions & 0 deletions test/results/kemonoparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@
"#category": ("", "kemonoparty", "favorite"),
"#class" : kemonoparty.KemonopartyFavoriteExtractor,
"#pattern" : kemonoparty.KemonopartyUserExtractor.pattern,
"#auth" : True,
"#count" : 3,
"#sha1_url": "f4b5b796979bcba824af84206578c79101c7f0e1",
},
Expand All @@ -306,6 +307,7 @@
"#category": ("", "kemonoparty", "favorite"),
"#class" : kemonoparty.KemonopartyFavoriteExtractor,
"#pattern" : kemonoparty.KemonopartyPostExtractor.pattern,
"#auth" : True,
"#count" : 3,
"#sha1_url": "ecfccf5f0d50b8d14caa7bbdcf071de5c1e5b90f",
},
Expand All @@ -315,6 +317,7 @@
"#category": ("", "kemonoparty", "favorite"),
"#class" : kemonoparty.KemonopartyFavoriteExtractor,
"#pattern" : kemonoparty.KemonopartyPostExtractor.pattern,
"#auth" : True,
"#count" : 3,
"#sha1_url": "4be8e84cb384a907a8e7997baaf6287b451783b5",
},
Expand Down
25 changes: 23 additions & 2 deletions test/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
},
}

AUTH = {
"pixiv",
"nijie",
"horne",
"seiga",
"instagram",
"twitter",
}


class TestExtractorResults(unittest.TestCase):

Expand Down Expand Up @@ -76,6 +85,18 @@ def _run_test(self, result):
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"])
Expand Down Expand Up @@ -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))


Expand Down Expand Up @@ -422,7 +443,7 @@ def test(self):
setattr(TestExtractorResults, method.__name__, method)


load_test_config()
generate_tests()
if __name__ == "__main__":
load_test_config()
unittest.main(warnings="ignore")

0 comments on commit 69726fc

Please sign in to comment.