def test_remove_old_empty_cache(self, mock_valid_timestamp):
        cache = Cache(5, 60.0)

        items = {
            "k1": ["v1", 0.1],
            "k2": ["v2", 0.5],
            "k3": ["v3", 1.8],
            "k4": ["v4", 55.5]
        }
        cache._items = items

        mock_valid_timestamp.return_value = True

        self.assertEqual(cache.remove_old(), 0)
        self.assertEqual(cache._items, items)
        mock_valid_timestamp.assert_has_calls(
            [mock.call(key) for key in items])
    def test_remove_old(self, mock_valid_timestamp):
        cache = Cache(5, 60.0)

        items = {
            "k1": ["v1", 0.1],
            "k2": ["v2", 0.5],
            "k3": ["v3", 1.8],
            "k4": ["v4", 55.5]
        }
        cache._items = items

        mock_valid_timestamp.side_effect = lambda x: True if x == "k4" else False

        self.assertEqual(cache.remove_old(), 3)
        self.assertEqual(cache._items, {"k4": ["v4", 55.5]})
        mock_valid_timestamp.assert_has_calls(
            [mock.call(key) for key in items])