mirror of
https://github.com/senju1337/senju.git
synced 2025-12-24 07:39:29 +00:00
test: add tests for get_latest_haiku_or_default
Refs: OPS-65
This commit is contained in:
parent
69db48af8b
commit
cf48ac8164
1 changed files with 17 additions and 1 deletions
|
|
@ -2,9 +2,10 @@
|
|||
# pytest fixtures to work
|
||||
from __future__ import annotations
|
||||
|
||||
from _pytest.mark.structures import store_mark
|
||||
import pytest # noqa: F401
|
||||
|
||||
from senju.haiku import Haiku
|
||||
from senju.haiku import DEFAULT_HAIKU, Haiku
|
||||
from senju.store_manager import StoreManager # noqa: F401
|
||||
|
||||
|
||||
|
|
@ -42,3 +43,18 @@ def test_load_latest_with_empty_store(temp_data_dir):
|
|||
store = StoreManager(temp_data_dir / "empty_store.json")
|
||||
h = store.get_id_of_latest_haiku()
|
||||
assert h is None
|
||||
|
||||
|
||||
def test_load_latest_or_default_with_empty(temp_data_dir):
|
||||
store = StoreManager(temp_data_dir / "load_or_default_empty.json")
|
||||
haiku = store.get_latest_haiku_or_default()
|
||||
assert haiku == DEFAULT_HAIKU
|
||||
|
||||
|
||||
def test_load_latest_or_default_with_non_empty(temp_data_dir):
|
||||
store = StoreManager(temp_data_dir / "load_or_default_not_empty.json")
|
||||
nonsense_test_haiku = Haiku(["nonsense", "test", "haiku"])
|
||||
store.save_haiku(nonsense_test_haiku)
|
||||
haiku = store.get_latest_haiku_or_default()
|
||||
assert haiku != DEFAULT_HAIKU
|
||||
assert haiku == nonsense_test_haiku
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue