Skip to content

Commit

Permalink
Fix tests (str > json responses)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstabenow committed Feb 27, 2023
1 parent 2d13271 commit fdf6397
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
8 changes: 7 additions & 1 deletion core_client/base/api/v3_config_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ def _build_request(

def _build_response(response: httpx.Response):
if response.status_code == 200:
response_200 = response.text
if (
response.headers["content-type"]
== "application/json; charset=UTF-8"
):
response_200 = response.json()
else:
response_200 = response.text
return response_200
else:
response_error = parse_obj_as(Error, response.json())
Expand Down
8 changes: 7 additions & 1 deletion core_client/base/api/v3_fs_delete_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ def _build_request(

def _build_response(response: httpx.Response):
if response.status_code == 200:
response_200 = response.text
if (
response.headers["content-type"]
== "application/json; charset=UTF-8"
):
response_200 = response.json()
else:
response_200 = response.text
return response_200
else:
response_error = parse_obj_as(Error, response.json())
Expand Down
16 changes: 14 additions & 2 deletions core_client/base/api/v3_fs_put_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,22 @@ def _build_request(

def _build_response(response: httpx.Response):
if response.status_code == 201:
response_201 = response.text
if (
response.headers["content-type"]
== "application/json; charset=UTF-8"
):
response_201 = response.json()
else:
response_201 = response.text
return response_201
elif response.status_code == 204:
response_204 = response.text
if (
response.headers["content-type"]
== "application/json; charset=UTF-8"
):
response_204 = response.json()
else:
response_204 = response.text
return response_204
else:
response_error = parse_obj_as(Error, response.json())
Expand Down
1 change: 1 addition & 0 deletions tests/4_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,4 @@ def test_v3_process_put_command_start():
def test_v3_process_delete():
res = client.v3_process_delete(id="test")
assert type(res) is str
assert res == "OK"

0 comments on commit fdf6397

Please sign in to comment.