tests: add test for request_haiku

Refs: OPS-70
This commit is contained in:
Christoph J. Scherr 2025-03-21 16:27:34 +01:00
parent aa236775ba
commit 897bf80e38
No known key found for this signature in database
GPG key ID: 9EB784BB202BB7BB
4 changed files with 36 additions and 9 deletions

View file

@ -5,6 +5,8 @@ from __future__ import annotations
import os
import json
import logging
from pytest_httpserver import HTTPServer
# do not remove this import. This is needed for
# pytest fixtures to work
@ -44,6 +46,15 @@ def test_get_haiku_json():
print(data)
def test_request_haiku():
haiku = Haiku.request_haiku("apple banana papaya")
def test_request_haiku(httpserver: HTTPServer):
httpserver.expect_request(
"/testhaiku").respond_with_json({"response":
"The apparition of these\n"
"faces in a crowd; Petal\n"
"on a wet, black bough."
})
haiku = Haiku.request_haiku(
"apple banana papaya", url=httpserver.url_for("/testhaiku"))
print(haiku)