diff options
author | mathieui <mathieui@mathieui.net> | 2019-02-02 17:42:24 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2019-02-02 17:42:24 +0100 |
commit | b42fafabb480db0653226a224006dae28c489665 (patch) | |
tree | da1cf27bfff0fe86f11eede9ac90f39e9bb75eba /tests/test_cache.py | |
parent | 3a44ec8f15c1d6267f6838b21b210d844202762c (diff) | |
download | slixmpp-b42fafabb480db0653226a224006dae28c489665.tar.gz slixmpp-b42fafabb480db0653226a224006dae28c489665.tar.bz2 slixmpp-b42fafabb480db0653226a224006dae28c489665.tar.xz slixmpp-b42fafabb480db0653226a224006dae28c489665.zip |
Make the cache encode and decode not crash if something goes wrong
Diffstat (limited to 'tests/test_cache.py')
-rw-r--r-- | tests/test_cache.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/test_cache.py b/tests/test_cache.py index 789e8bbf..78e9ee03 100644 --- a/tests/test_cache.py +++ b/tests/test_cache.py @@ -34,9 +34,14 @@ class TestCacheClass(SlixTest): ) def testFileSystemCache(self): + def failing_decode(value): + if value == "failme": + raise Exception("you failed") + return value with TemporaryDirectory() as tmpdir: - cache = FileSystemCache(tmpdir, "test") + cache = FileSystemCache(tmpdir, "test", decode=failing_decode) cache.store("test", "test_value") + cache.store("test2", "failme") self.assertEqual( cache.retrieve("test"), "test_value" @@ -47,6 +52,11 @@ class TestCacheClass(SlixTest): None ) + self.assertEqual( + cache.retrieve("test2"), + None + ) + def testFileSystemPerJidCache(self): with TemporaryDirectory() as tmpdir: cache = FileSystemPerJidCache(tmpdir, "test") |