Fixed #20: I can parse simple concepts

This commit is contained in:
2023-07-09 18:08:47 +02:00
parent ba397b0b72
commit 57f9ce2bbb
44 changed files with 2462 additions and 149 deletions
+39
View File
@@ -51,6 +51,15 @@ def test_not_found_is_returned_when_not_found():
assert cache.get("foo") is NotFound
def test_i_can_remove_an_item():
cache = FastCache()
cache.put("key1", "value1")
cache.put("to_keep1", "to_keep_value1")
cache.remove("key1")
assert cache.cache == {"to_keep1": "to_keep_value1"}
def test_i_can_evict_by_key():
cache = FastCache()
cache.put("key1", "value1")
@@ -109,3 +118,33 @@ def test_i_can_copy():
cache.put("key3", "value3")
assert cache.copy() == {"key1": "value1", "key2": "value2", "key3": "value3"}
def test_i_can_take_snapshots_and_revert():
# Test that I can create restoration points
# and come back later to them
cache = FastCache()
cache.put("key1", "value1")
cache.snapshot()
cache.put("key2", "value2")
cache.put("key3", "value3")
cache.snapshot()
cache.put("key4", "value4")
cache.put("key5", "value5")
assert cache.cache == {"key1": "value1",
"key2": "value2",
"key3": "value3",
"key4": "value4",
"key5": "value5"}
cache.revert_snapshot()
assert cache.cache == {"key1": "value1",
"key2": "value2",
"key3": "value3"}
cache.revert_snapshot()
assert cache.cache == {"key1": "value1"}
cache.revert_snapshot() # no effect if nothing to revert
assert cache.cache == {"key1": "value1"}