tests: add some tests to test the methods of Haiku

Refs: OPS-70
This commit is contained in:
Christoph J. Scherr 2025-03-21 15:26:46 +01:00
parent 0ce42f595c
commit aa236775ba
No known key found for this signature in database
GPG key ID: 9EB784BB202BB7BB

View file

@ -4,12 +4,14 @@
from __future__ import annotations from __future__ import annotations
import os import os
import json
# do not remove this import. This is needed for # do not remove this import. This is needed for
# pytest fixtures to work # pytest fixtures to work
import pytest # noqa: F401 import pytest # noqa: F401
import senju # noqa: F401 import senju
from senju.haiku import Haiku # noqa: F401
# Note: these weird arguments are an indicator of what should be dome # Note: these weird arguments are an indicator of what should be dome
# before. For example, `temp_data_dir` is a function in `conftest.py`. If we # before. For example, `temp_data_dir` is a function in `conftest.py`. If we
@ -28,3 +30,20 @@ def test_temp_data_dir(temp_data_dir):
with open(testpath, "w") as f: with open(testpath, "w") as f:
f.write("that dir actually works") f.write("that dir actually works")
os.remove(testpath) os.remove(testpath)
def test_create_haiku():
haiku = Haiku(["line number 1", "line number 2", "line number 3"])
print(haiku)
def test_get_haiku_json():
haiku = Haiku(["line number 1", "line number 2", "line number 3"])
data_raw: str = haiku.get_json()
data = json.loads(data_raw)
print(data)
def test_request_haiku():
haiku = Haiku.request_haiku("apple banana papaya")
print(haiku)