Skip to content

Commit 2e318e1

Browse files
committed
Added test to cover invalid variable types.
1 parent dc8f7ff commit 2e318e1

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/to_refactor/python/test_tracer_analysis_routes.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,29 @@ def test_empty_payload(rest_client):
226226
response = rest_client.post("/us/tracer-analysis", json={})
227227
assert response.status_code == 400
228228
assert "No payload provided" in json.loads(response.data)["message"]
229+
230+
231+
def test_null_payload(rest_client):
232+
"""Test that null payload is rejected"""
233+
response = rest_client.post(
234+
"/us/tracer-analysis", data="{}", content_type="application/json"
235+
)
236+
assert response.status_code == 400
237+
assert "No payload provided" in json.loads(response.data)["message"]
238+
239+
240+
def test_validate_tracer_analysis_payload_failure(rest_client):
241+
"""Test handling of invalid payload from validate_tracer_analysis_payload"""
242+
response = rest_client.post(
243+
"/us/tracer-analysis",
244+
json={
245+
# Missing required field 'variable'
246+
"household_id": VALID_HOUSEHOLD_ID,
247+
"policy_id": VALID_POLICY_ID,
248+
},
249+
)
250+
assert response.status_code == 400
251+
assert (
252+
"Missing required key: variable"
253+
in json.loads(response.data)["message"]
254+
)

0 commit comments

Comments
 (0)