MCPcopy
hub / github.com/django/django / test_cull_queries

Method test_cull_queries

tests/cache/tests.py:1293–1310  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1291 cache.delete_many(["a", "b", "c"])
1292
1293 def test_cull_queries(self):
1294 old_max_entries = cache._max_entries
1295 # Force _cull to delete on first cached record.
1296 cache._max_entries = -1
1297 with CaptureQueriesContext(connection) as captured_queries:
1298 try:
1299 cache.set("force_cull", "value", 1000)
1300 finally:
1301 cache._max_entries = old_max_entries
1302 num_count_queries = sum("COUNT" in query["sql"] for query in captured_queries)
1303 self.assertEqual(num_count_queries, 1)
1304 # Column names are quoted.
1305 for query in captured_queries:
1306 sql = query["sql"]
1307 if "expires" in sql:
1308 self.assertIn(connection.ops.quote_name("expires"), sql)
1309 if "cache_key" in sql:
1310 self.assertIn(connection.ops.quote_name("cache_key"), sql)
1311
1312 def test_delete_cursor_rowcount(self):
1313 """

Callers

nothing calls this directly

Calls 3

setMethod · 0.45
quote_nameMethod · 0.45

Tested by

no test coverage detected