diff options
| author | 2025-10-07 02:11:52 -0400 | |
|---|---|---|
| committer | 2025-10-07 02:11:52 -0400 | |
| commit | 83e1e051b8c0e622ef5f61c1955c47b4bde95b57 (patch) | |
| tree | 544a434cb398d2adb8b8a2d553dc1c9a44b4ee1d /test | |
| parent | f1612851ae9fe68c7444fb31e786503868aeaa7c (diff) | |
| parent | bbe7fac03d881662a458e7fbf870c9d71f5257f4 (diff) | |
Update upstream source from tag 'upstream/1.30.9'
Update to upstream version '1.30.9'
with Debian dir 46cc56e13f05f4465cc64f67b4d7b775a95bd87a
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_downloader.py | 2 | ||||
| -rw-r--r-- | test/test_postprocessor.py | 54 | ||||
| -rw-r--r-- | test/test_results.py | 11 |
3 files changed, 65 insertions, 2 deletions
diff --git a/test/test_downloader.py b/test/test_downloader.py index ecd8b85..f6c3dbe 100644 --- a/test/test_downloader.py +++ b/test/test_downloader.py @@ -386,6 +386,8 @@ SAMPLES = { ("mp3" , b"\xFF\xFB"), ("mp3" , b"\xFF\xF3"), ("mp3" , b"\xFF\xF2"), + ("m3u8", b"#EXTM3U\n#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=200000"), + ("mpd" , b'<MPD xmlns="urn:mpeg:dash:schema:mpd:2011"'), ("zip" , b"PK\x03\x04"), ("zip" , b"PK\x05\x06"), ("zip" , b"PK\x07\x08"), diff --git a/test/test_postprocessor.py b/test/test_postprocessor.py index 2902fea..17b36b6 100644 --- a/test/test_postprocessor.py +++ b/test/test_postprocessor.py @@ -21,7 +21,7 @@ from datetime import datetime sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from gallery_dl import extractor, output, path, util, exception # noqa E402 -from gallery_dl import postprocessor, config # noqa E402 +from gallery_dl import postprocessor, config, archive # noqa E402 from gallery_dl.postprocessor.common import PostProcessor # noqa E402 @@ -39,7 +39,7 @@ class FakeJob(): self.get_logger = logging.getLogger self.hooks = collections.defaultdict(list) - def register_hooks(self, hooks, options): + def register_hooks(self, hooks, options=None): for hook, callback in hooks.items(): self.hooks[hook].append(callback) @@ -353,6 +353,23 @@ class ExecTest(BasePostprocessorTest): ) i.wait.assert_called_once_with() + def test_archive(self): + pp = self._create({ + "command": ["echo", "foobar"], + "archive": ":memory:", + "event" : "finalize", + }) + + self.assertIsInstance(pp.archive, archive.DownloadArchive) + + with patch.object(pp.archive, "add") as m_aa, \ + patch.object(pp.archive, "close") as m_ac: + self._trigger(("finalize",)) + pp.archive.close() + + m_aa.assert_called_once_with(self.pathfmt.kwdict) + m_ac.assert_called_once() + class HashTest(BasePostprocessorTest): @@ -811,6 +828,22 @@ class MetadataTest(BasePostprocessorTest): } """) + def test_archive(self): + pp = self._create({ + "archive": ":memory:", + "event" : "finalize", + }) + + self.assertIsInstance(pp.archive, archive.DownloadArchive) + + with patch.object(pp.archive, "add") as m_aa, \ + patch.object(pp.archive, "close") as m_ac: + self._trigger(("finalize",)) + pp.archive.close() + + m_aa.assert_called_once_with(self.pathfmt.kwdict) + m_ac.assert_called_once() + def _output(self, mock): return "".join( call[1][0] @@ -890,6 +923,23 @@ class PythonTest(BasePostprocessorTest): with self.assertRaises(exception.StopExtraction): self._trigger() + def test_archive(self): + pp = self._create({ + "expression": "True", + "archive" : ":memory:", + "event" : "finalize", + }) + + self.assertIsInstance(pp.archive, archive.DownloadArchive) + + with patch.object(pp.archive, "add") as m_aa, \ + patch.object(pp.archive, "close") as m_ac: + self._trigger(("finalize",)) + pp.archive.close() + + m_aa.assert_called_once_with(self.pathfmt.kwdict) + m_ac.assert_called_once() + def _write_module(self, path): with open(path, "w") as fp: fp.write(""" diff --git a/test/test_results.py b/test/test_results.py index 7e024b8..2e2eaa9 100644 --- a/test/test_results.py +++ b/test/test_results.py @@ -348,6 +348,17 @@ class TestExtractorResults(unittest.TestCase): for _ in value: len_value += 1 self.assertEqual(int(length), len_value, msg=path) + elif test.startswith("hash:"): + digest = test[5:].lower() + msg = f"{path} / {digest}" + if digest == "md5": + self.assertRegex(value, r"^[0-9a-fA-F]{32}$", msg) + elif digest == "sha1": + self.assertRegex(value, r"^[0-9a-fA-F]{40}$", msg) + elif digest == "sha256": + self.assertRegex(value, r"^[0-9a-fA-F]{64}$", msg) + elif digest == "sha512": + self.assertRegex(value, r"^[0-9a-fA-F]{128}$", msg) elif test.startswith("iso:"): iso = test[4:] if iso in ("dt", "datetime", "8601"): |
