diff options
| author | Jacob Burch <jacobburch@gmail.com> | 2013-05-18 12:54:59 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-05-18 15:39:42 +0200 |
| commit | 89955cc35f3636684ea6f2a6c9504b35a3050f0f (patch) | |
| tree | 99e4f6a70e3ce3826aabda970d7f25af0fbc4b30 /tests | |
| parent | e0df647143dd595aba0e9f077703775a226d015f (diff) | |
Fixed #9595 -- Allow non-expiring cache timeouts.
Also, streamline the use of 0 and None between cache backends.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cache/tests.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 00c51638b7..4f7ee8b525 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -441,6 +441,34 @@ class BaseCacheTests(object): self.assertEqual(self.cache.get('key3'), 'sausage') self.assertEqual(self.cache.get('key4'), 'lobster bisque') + def test_forever_timeout(self): + ''' + Passing in None into timeout results in a value that is cached forever + ''' + self.cache.set('key1', 'eggs', None) + self.assertEqual(self.cache.get('key1'), 'eggs') + + self.cache.add('key2', 'ham', None) + self.assertEqual(self.cache.get('key2'), 'ham') + + self.cache.set_many({'key3': 'sausage', 'key4': 'lobster bisque'}, None) + self.assertEqual(self.cache.get('key3'), 'sausage') + self.assertEqual(self.cache.get('key4'), 'lobster bisque') + + def test_zero_timeout(self): + ''' + Passing in None into timeout results in a value that is cached forever + ''' + self.cache.set('key1', 'eggs', 0) + self.assertEqual(self.cache.get('key1'), None) + + self.cache.add('key2', 'ham', 0) + self.assertEqual(self.cache.get('key2'), None) + + self.cache.set_many({'key3': 'sausage', 'key4': 'lobster bisque'}, 0) + self.assertEqual(self.cache.get('key3'), None) + self.assertEqual(self.cache.get('key4'), None) + def test_float_timeout(self): # Make sure a timeout given as a float doesn't crash anything. self.cache.set("key1", "spam", 100.2) |
