diff options
| author | 2022-06-28 19:54:18 -0400 | |
|---|---|---|
| committer | 2022-06-28 19:54:18 -0400 | |
| commit | ce35450b5308adab049c5bd99095986d4c607027 (patch) | |
| tree | f0c2b600f8ef720941bdf615164b942c6c4a5d07 /test | |
| parent | 25442ea49f031d4d2df3353dd7e9ad2080e332da (diff) | |
New upstream version 1.22.3.upstream/1.22.3
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_cookies.py | 16 | ||||
| -rw-r--r-- | test/test_formatter.py | 21 | ||||
| -rw-r--r-- | test/test_results.py | 1 |
3 files changed, 31 insertions, 7 deletions
diff --git a/test/test_cookies.py b/test/test_cookies.py index 188b54c..335fa3d 100644 --- a/test/test_cookies.py +++ b/test/test_cookies.py @@ -89,7 +89,7 @@ class TestCookiedict(unittest.TestCase): self.assertEqual(sorted(cookies.values()), sorted(self.cdict.values())) def test_domain(self): - for category in ["exhentai", "idolcomplex", "nijie"]: + for category in ["exhentai", "idolcomplex", "nijie", "horne"]: extr = _get_extractor(category) cookies = extr.session.cookies for key in self.cdict: @@ -107,7 +107,8 @@ class TestCookieLogin(unittest.TestCase): extr_cookies = { "exhentai" : ("ipb_member_id", "ipb_pass_hash"), "idolcomplex": ("login", "pass_hash"), - "nijie" : ("nemail", "nlogin"), + "nijie" : ("nijie_tok",), + "horne" : ("horne_tok",), } for category, cookienames in extr_cookies.items(): cookies = {name: "value" for name in cookienames} @@ -199,10 +200,13 @@ class TestCookieUtils(unittest.TestCase): def _get_extractor(category): - for extr in extractor.extractors(): - if extr.category == category and hasattr(extr, "_login_impl"): - url = next(extr._get_tests())[0] - return extr.from_url(url) + URLS = { + "exhentai" : "https://exhentai.org/g/1200119/d55c44d3d0/", + "idolcomplex": "https://idol.sankakucomplex.com/post/show/1", + "nijie" : "https://nijie.info/view.php?id=1", + "horne" : "https://horne.red/view.php?id=1", + } + return extractor.find(URLS[category]) if __name__ == "__main__": diff --git a/test/test_formatter.py b/test/test_formatter.py index efb6963..5b8ca0a 100644 --- a/test/test_formatter.py +++ b/test/test_formatter.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright 2021 Mike Fährmann +# Copyright 2021-2022 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -56,6 +56,7 @@ class TestFormatter(unittest.TestCase): self._run_test("{t!d:%Y-%m-%d}", "2010-01-01") self._run_test("{dt!T}", "1262304000") self._run_test("{l!j}", '["a", "b", "c"]') + self._run_test("{dt!j}", '"2010-01-01 00:00:00"') with self.assertRaises(KeyError): self._run_test("{a!q}", "hello world") @@ -134,6 +135,21 @@ class TestFormatter(unittest.TestCase): self._run_test("{a[:50:2]}", v[:50:2]) self._run_test("{a[::]}" , v) + self._run_test("{a:[1:10]}" , v[1:10]) + self._run_test("{a:[-10:-1]}", v[-10:-1]) + self._run_test("{a:[5:]}" , v[5:]) + self._run_test("{a:[50:]}", v[50:]) + self._run_test("{a:[:5]}" , v[:5]) + self._run_test("{a:[:50]}", v[:50]) + self._run_test("{a:[:]}" , v) + self._run_test("{a:[1:10:2]}" , v[1:10:2]) + self._run_test("{a:[-10:-1:2]}", v[-10:-1:2]) + self._run_test("{a:[5::2]}" , v[5::2]) + self._run_test("{a:[50::2]}", v[50::2]) + self._run_test("{a:[:5:2]}" , v[:5:2]) + self._run_test("{a:[:50:2]}", v[:50:2]) + self._run_test("{a:[::]}" , v) + def test_maxlen(self): v = self.kwdict["a"] self._run_test("{a:L5/foo/}" , "foo") @@ -176,6 +192,9 @@ class TestFormatter(unittest.TestCase): # join-and-replace self._run_test("{l:J-/Rb/E/}", "a-E-c") + # join and slice + self._run_test("{l:J-/[1:-1]}", "-b-") + # optional-and-maxlen self._run_test("{d[a]:?</>/L1/too long/}", "<too long>") self._run_test("{d[c]:?</>/L5/too long/}", "") diff --git a/test/test_results.py b/test/test_results.py index 6a186fd..d3debc6 100644 --- a/test/test_results.py +++ b/test/test_results.py @@ -312,6 +312,7 @@ def setup_test_config(): config.set(("extractor", "nijie") , "username", email) config.set(("extractor", "seiga") , "username", email) + config.set(("extractor", "horne") , "username", email2) config.set(("extractor", "pinterest") , "username", email2) config.set(("extractor", "pinterest") , "username", None) # login broken |
