mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
add tests for "Extractors" in oauth.py (#670)
This commit is contained in:
parent
04bd0472de
commit
3b50c4f49d
@ -234,5 +234,52 @@ class TestExtractorWait(unittest.TestCase):
|
||||
return int(parts[0]) * 3600 + int(parts[1]) * 60 + int(parts[2])
|
||||
|
||||
|
||||
class TextExtractorOAuth(unittest.TestCase):
|
||||
|
||||
def test_oauth1(self):
|
||||
for category in ("flickr", "smugmug", "tumblr"):
|
||||
extr = extractor.find("oauth:" + category)
|
||||
|
||||
with patch.object(extr, "_oauth1_authorization_flow") as m:
|
||||
for msg in extr:
|
||||
pass
|
||||
self.assertEqual(len(m.mock_calls), 1)
|
||||
|
||||
def test_oauth2(self):
|
||||
for category in ("deviantart", "reddit"):
|
||||
extr = extractor.find("oauth:" + category)
|
||||
|
||||
with patch.object(extr, "_oauth2_authorization_code_grant") as m:
|
||||
for msg in extr:
|
||||
pass
|
||||
self.assertEqual(len(m.mock_calls), 1)
|
||||
|
||||
def test_oauth2_mastodon(self):
|
||||
extr = extractor.find("oauth:mastodon:pawoo.net")
|
||||
|
||||
with patch.object(extr, "_oauth2_authorization_code_grant") as m, \
|
||||
patch.object(extr, "_register") as r:
|
||||
for msg in extr:
|
||||
pass
|
||||
self.assertEqual(len(r.mock_calls), 0)
|
||||
self.assertEqual(len(m.mock_calls), 1)
|
||||
|
||||
def test_oauth2_mastodon_unknown(self):
|
||||
extr = extractor.find("oauth:mastodon:example.com")
|
||||
|
||||
with patch.object(extr, "_oauth2_authorization_code_grant") as m, \
|
||||
patch.object(extr, "_register") as r:
|
||||
r.return_value = {
|
||||
"client-id" : "foo",
|
||||
"client-secret": "bar",
|
||||
}
|
||||
|
||||
for msg in extr:
|
||||
pass
|
||||
|
||||
self.assertEqual(len(r.mock_calls), 1)
|
||||
self.assertEqual(len(m.mock_calls), 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user