def test_missing_table_cache_key(self): qs = Test.objects.all() self.assert_tables(qs, Test) self.assert_query_cached(qs) table_cache_key = cachalot_settings.CACHALOT_TABLE_KEYGEN( connection.alias, Test._meta.db_table) cachalot_caches.get_cache().delete(table_cache_key) self.assert_query_cached(qs)
def test_broken_query_cache_value(self): """ In some undetermined cases, cache.get_many return wrong values such as `None` or other invalid values. They should be gracefully handled. See https://github.com/noripyt/django-cachalot/issues/110 This test artificially creates a wrong value, but it’s usually a cache backend bug that leads to these wrong values. """ qs = Test.objects.all() self.assert_tables(qs, Test) self.assert_query_cached(qs) query_cache_key = cachalot_settings.CACHALOT_QUERY_KEYGEN( qs.query.get_compiler(DEFAULT_DB_ALIAS)) cachalot_caches.get_cache().set(query_cache_key, (), cachalot_settings.CACHALOT_TIMEOUT) self.assert_query_cached(qs)