예제 #1
0
    def test_valid_timestamp_true(self, mock_time):
        cache = Cache(5, 60.0)
        cache._items = {"k1": ["v1", 20.0]}

        mock_time.return_value = 50.0
        self.assertTrue(cache._valid_timestamp("k1"))
        mock_time.assert_called_once()

        mock_time.reset_mock()

        mock_time.return_value = 80.0
        self.assertTrue(cache._valid_timestamp("k1"))
        mock_time.assert_called_once()
예제 #2
0
    def test_valid_timestamp_false(self, mock_time):
        cache = Cache(5, 60.0)

        cache._items = {"k1": ["v1", 20.0]}
        mock_time.return_value = 100.0
        self.assertFalse(cache._valid_timestamp("k1"))
        mock_time.assert_called_once()