diff options
author | dirkf <fieldhouse@gmx.net> | 2022-09-01 13:28:30 +0100 |
---|---|---|
committer | dirkf <fieldhouse@gmx.net> | 2022-09-01 13:28:30 +0100 |
commit | 218c423bc042674a8834ffc09520a94fbbe7b138 (patch) | |
tree | c3d3cedf62212ff69399c712b5edd8ac503e9959 /test | |
parent | 55c823634db890a328ffc23588fcd6f35d9b3ddf (diff) | |
download | youtube-dl-218c423bc042674a8834ffc09520a94fbbe7b138.tar.gz youtube-dl-218c423bc042674a8834ffc09520a94fbbe7b138.tar.xz |
[cache] Add cache validation by program version, based on yt-dlp
Diffstat (limited to 'test')
-rw-r--r-- | test/test_cache.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/test/test_cache.py b/test/test_cache.py index a16160142..931074aa1 100644 --- a/test/test_cache.py +++ b/test/test_cache.py @@ -3,17 +3,18 @@ from __future__ import unicode_literals -import shutil - # Allow direct execution import os import sys import unittest sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +import shutil from test.helper import FakeYDL from youtube_dl.cache import Cache +from youtube_dl.utils import version_tuple +from youtube_dl.version import __version__ def _is_empty(d): @@ -54,6 +55,17 @@ class TestCache(unittest.TestCase): self.assertFalse(os.path.exists(self.test_dir)) self.assertEqual(c.load('test_cache', 'k.'), None) + def test_cache_validation(self): + ydl = FakeYDL({ + 'cachedir': self.test_dir, + }) + c = Cache(ydl) + obj = {'x': 1, 'y': ['รค', '\\a', True]} + c.store('test_cache', 'k.', obj) + self.assertEqual(c.load('test_cache', 'k.', min_ver='1970.01.01'), obj) + new_version = '.'.join(('%d' % ((v + 1) if i == 0 else v, )) for i, v in enumerate(version_tuple(__version__))) + self.assertIs(c.load('test_cache', 'k.', min_ver=new_version), None) + if __name__ == '__main__': unittest.main() |