def test_cache_get_missing_key(self, CacheStats): store = MagicMock() store.__getitem__.return_value = None c = Cache(store=MagicMock(return_value=store)) foo = c.get('foo') CacheStats.return_value.miss.assert_called_once_with() self.assertIsNone(foo)
def test_cache_get_missing_key(self, CacheStats): store = MagicMock() store.__getitem__.return_value = None c = Cache(store=MagicMock(return_value=store)) foo = c.get('foo') CacheStats.return_value.miss.assert_called_once_with() self.assertIsNone(foo)
def test_cache_get_expired_key(self, CacheStats): store = MagicMock() store.__getitem__.return_value.is_expired.return_value = True c = Cache(store=MagicMock(return_value=store)) foo = c.get('foo') store.__delitem__.assert_called_once_with('foo') CacheStats.return_value.miss.assert_called_once_with(expired=True) self.assertIsNone(foo)
def test_cache_get_expired_key(self, CacheStats): store = MagicMock() store.__getitem__.return_value.is_expired.return_value = True c = Cache(store=MagicMock(return_value=store)) foo = c.get('foo') store.__delitem__.assert_called_once_with('foo') CacheStats.return_value.miss.assert_called_once_with(expired=True) self.assertIsNone(foo)
def test_cache_get_existing_key(self, CacheStats): store = MagicMock() store.__getitem__.return_value.is_expired.return_value = False c = Cache(store=MagicMock(return_value=store)) foo = c.get('foo') store.__getitem__.assert_called_once_with('foo') CacheStats.return_value.hit.assert_called_once_with() store.__getitem__.return_value.touch.assert_called_once_with() self.assertEqual(foo, store.__getitem__.return_value.value)
def test_cache_get_existing_key(self, CacheStats): store = MagicMock() store.__getitem__.return_value.is_expired.return_value = False c = Cache(store=MagicMock(return_value=store)) foo = c.get('foo') store.__getitem__.assert_called_once_with('foo') CacheStats.return_value.hit.assert_called_once_with() store.__getitem__.return_value.touch.assert_called_once_with() self.assertEqual(foo, store.__getitem__.return_value.value)