MCPcopy Create free account
hub / github.com/requests-cache/requests-cache / test_count

Method test_count

tests/integration/test_sqlite.py:369–377  ·  view source on GitHub ↗

count() should work the same as len(), but with the option to exclude expired responses

(self)

Source from the content-addressed store, hash-verified

367 assert session.cache.db_path == session.cache.responses.db_path
368
369 def test_count(self):
370 """count() should work the same as len(), but with the option to exclude expired responses"""
371 session = self.init_session()
372 now = utcnow()
373 session.cache.responses['key_1'] = CachedResponse(expires=now + timedelta(1))
374 session.cache.responses['key_2'] = CachedResponse(expires=now - timedelta(1))
375
376 assert session.cache.count() == 2
377 assert session.cache.count(expired=False) == 1
378
379 def test_delete__single_key(self):
380 """Vacuum should not be used after delete if there is only a single key"""

Callers

nothing calls this directly

Calls 4

utcnowFunction · 0.90
CachedResponseClass · 0.90
init_sessionMethod · 0.80
countMethod · 0.45

Tested by

no test coverage detected