From 2fa911c6657ea2f402d136f8c0ca6b1a1ea2b728 Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Sun, 23 Mar 2025 13:31:46 +0100 Subject: [PATCH] test: add test_request_haiku_respondse_bad Refs: OPS-70 OPS-81 --- tests/test_haiku.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_haiku.py b/tests/test_haiku.py index ac6f063..b1a8f73 100644 --- a/tests/test_haiku.py +++ b/tests/test_haiku.py @@ -6,6 +6,7 @@ from __future__ import annotations import os import json from pytest_httpserver import HTTPServer +import requests # do not remove this import. This is needed for # pytest fixtures to work @@ -68,3 +69,13 @@ def test_request_haiku(httpserver: HTTPServer): assert haiku.lines[1] == "faces in a crowd; Petal" assert haiku.lines[2] == "on a wet, black bough." assert len(haiku.lines) == 3 + + +def test_request_haiku_respondse_bad(httpserver: HTTPServer): + with pytest.raises(requests.exceptions.JSONDecodeError): + + httpserver.expect_request( + "/testhaiku").respond_with_data("this is completely wrong" + ("A" * 50 + "\n") * 20) + + _haiku = Haiku.request_haiku( + "apple banana papaya", url=httpserver.url_for("/testhaiku"))