From ed77ae35c38c90c7444d05fb4c592ca2c18d59cf Mon Sep 17 00:00:00 2001 From: jukkap Date: Thu, 1 Feb 2024 11:47:58 +0200 Subject: [PATCH] Test: Add asserts that raised http exception has the correct response code and error string --- api/test/test_covjson.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/test/test_covjson.py b/api/test/test_covjson.py index ac2d980f..28545411 100644 --- a/api/test/test_covjson.py +++ b/api/test/test_covjson.py @@ -94,10 +94,14 @@ def test_empty_response_convert(): test_data = load_json("test/test_data/test_empty_proto.json") response = create_mock_obs_response(test_data) - # Expect to get an HTTPException when converting an empty response - with pytest.raises(HTTPException): + # Expect to get an HTTPException with status code of 404 and detail of + # "No data found" when converting an empty response + with pytest.raises(HTTPException) as exception_info: Covjson().convert(response) + assert exception_info.value.detail == "No data found" + assert exception_info.value.status_code == 404 + def create_mock_obs_response(json_data): response = dstore.GetObsResponse()