diff --git a/tests/test_persistence.py b/tests/test_persistence.py index 9d0a83d..88e5431 100644 --- a/tests/test_persistence.py +++ b/tests/test_persistence.py @@ -1,4 +1,6 @@ -from untitled import content, model, persistence +import time + +from untitled import content, model, persistence, rules def test_save_load_roundtrip(tmp_path): @@ -45,6 +47,25 @@ def test_migration(tmp_path): assert loaded.cat.last_updated +def test_decay_and_feed(): + cat = model.Save( + version=content.SAVE_VERSION, + cat=model.Cat( + "Fry", + { + "size": "tiny", + "color": "tuxedo", + "eyes": "blue", + "personality": "judges you silently", + }, + ), + ) + rules.reconcile(cat.cat, time.time() + 3600) + assert cat.cat.fullness < 98 + rules.feed(cat.cat) + assert cat.cat.fullness > 98 and cat.cat.fullness <= 100 + + def test_list_saves(tmp_path): open(tmp_path / "test.kitten", "w").close() open(tmp_path / "test2.kitten", "w").close() diff --git a/untitled/rules.py b/untitled/rules.py index 5e0890d..fbb97bd 100644 --- a/untitled/rules.py +++ b/untitled/rules.py @@ -30,4 +30,4 @@ def reconcile(cat, now): def feed(cat, amount=100): cat.fullness += amount if cat.fullness > 100: - cat.fullnesss = 100 + cat.fullness = 100