def test_accesses_value_and_moves_to_front(self): """ Moves a value to the front of the cache if it's accessed """ cache = LRUCache(10, "first") cache.add_value("second") cache.add_value("third") cache.access_value("first") front_value = cache._front.get_value() back_value = cache._back.get_value() self.assertEqual(front_value, "first") self.assertEqual(back_value, "second")
def test_returns_true_if_value_found(self): """ Returns True if the value is found in the cache """ cache = LRUCache(100) cache.add_value("test") result = cache.access_value("test") self.assertEqual(result, True)
def test_returns_false_if_value_not_found(self): """ Returns False if the value is not found in the cache """ cache = LRUCache(100) cache.add_value("test") result = cache.access_value("this value cannot be found") self.assertEqual(result, False)