diff options
| author | Guillermo BonvehĂ <gbonvehi@gmail.com> | 2020-06-20 04:33:24 -0300 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-06-22 07:10:16 +0200 |
| commit | b2e2489d807de360068f5a34c57d5345e526caf3 (patch) | |
| tree | 0cbcb9c32fc99680e66ab4bc08161df596b54167 /tests | |
| parent | ac7f7eab0fad18fffc465bc4fdc092bcb2de2d80 (diff) | |
[3.1.x] Fixed #31728 -- Fixed cache culling when no key is found for deletion.
DatabaseCache._cull implementation could fail if no key was found to
perform a deletion in the table. This prevented the new cache key/value
from being correctly added.
Backport of f386454d1302b66d0eb331ed0ae9e4811e2f3a15 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cache/tests.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 9682cd44ee..b85b5e8501 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -621,6 +621,20 @@ class BaseCacheTests: def test_zero_cull(self): self._perform_cull_test('zero_cull', 50, 19) + def test_cull_delete_when_store_empty(self): + try: + cull_cache = caches['cull'] + except InvalidCacheBackendError: + self.skipTest("Culling isn't implemented.") + old_max_entries = cull_cache._max_entries + # Force _cull to delete on first cached record. + cull_cache._max_entries = -1 + try: + cull_cache.set('force_cull_delete', 'value', 1000) + self.assertIs(cull_cache.has_key('force_cull_delete'), True) + finally: + cull_cache._max_entries = old_max_entries + def _perform_invalid_key_test(self, key, expected_warning): """ All the builtin backends should warn (except memcached that should |
