Skip to content

Commit 4620e5f

Browse files
committed
Added tests to cover the code at line 39 in the tracer_analysis_routes.py file.
1 parent e5f63de commit 4620e5f

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

tests/to_refactor/python/test_tracer_analysis_routes.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
)
88

99
# constants
10-
VALID_HOUSEHOLD_ID = "123"
11-
VALID_POLICY_ID = "456"
10+
VALID_HOUSEHOLD_ID = 123
11+
VALID_POLICY_ID = 456
1212
INVALID_HOUSEHOLD_ID = "abc123"
1313
INVALID_POLICY_ID = "invalid-id"
1414
TEST_VARIABLE = "disposable_income"
15-
INVALID_VARIABLE = "123"
15+
INVALID_VARIABLE = 123
1616

1717

1818
@patch("policyengine_api.services.tracer_analysis_service.local_database")
@@ -191,7 +191,7 @@ def test_invalid_variable_type(rest_client):
191191
json={
192192
"household_id": VALID_HOUSEHOLD_ID,
193193
"policy_id": VALID_POLICY_ID,
194-
"variable": 123,
194+
"variable": INVALID_VARIABLE,
195195
},
196196
)
197197
assert response.status_code == 400
@@ -212,3 +212,13 @@ def test_empty_payload(rest_client):
212212
response = rest_client.post("/us/tracer-analysis", json={})
213213
assert response.status_code == 400
214214
assert "No payload provided" in json.loads(response.data)["message"]
215+
216+
217+
def test_invalid_content_type(rest_client):
218+
"""Test that non-JSON content type is rejected"""
219+
response = rest_client.post(
220+
"/us/tracer-analysis",
221+
data="some data",
222+
content_type="text/plain", # Invalid content type
223+
)
224+
assert response.status_code == 415

0 commit comments

Comments
 (0)