[tests] implement explicitly disabling auth

This commit is contained in:
Mike Fährmann
2024-02-12 23:39:45 +01:00
parent cae77e85f8
commit 8f27f43d4d
2 changed files with 18 additions and 11 deletions

View File

@@ -49,6 +49,14 @@ AUTH = {
"twitter",
}
AUTH_CONFIG = (
"username",
"cookies",
"api-key",
"client-id",
"refresh-token",
)
class TestExtractorResults(unittest.TestCase):
@@ -88,14 +96,16 @@ class TestExtractorResults(unittest.TestCase):
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:
auth = result.get("#auth")
if auth is None:
auth = (result["#category"][1] in AUTH)
elif not auth:
for key in AUTH_CONFIG:
config.set((), key, None)
if auth:
extr = result["#class"].from_url(result["#url"])
if not any(extr.config(key) for key in (
"username", "cookies", "api-key", "client-id",
"refresh-token")):
if not any(extr.config(key) for key in AUTH_CONFIG):
msg = "no auth"
self._skipped.append((result["#url"], msg))
self.skipTest(msg)