Пример #1
0
    def test_get_item_in_cache_invalid_timestamp(self, mock_valid_timestamp):
        cache = Cache(5, 60.0)

        cache._items = {"k1": ["v1", 0.1]}
        mock_valid_timestamp.return_value = False

        self.assertIsNone(cache.get("k1"))
        mock_valid_timestamp.assert_called_once_with("k1")
Пример #2
0
    def test_get_item_in_cache_valid_timestamp(self, mock_valid_timestamp):
        cache = Cache(5, 60.0)

        cache._items = {"k1": ["v1", 0.1]}
        mock_valid_timestamp.return_value = True

        self.assertEqual(cache.get("k1"), "v1")
        mock_valid_timestamp.assert_called_once_with("k1")
Пример #3
0
    def test_get_item_not_in_cache(self):
        cache = Cache(5, 60.0)

        self.assertIsNone(cache.get("k1"))