Skip to content

Commit

Permalink
Merge pull request #155 from fridex/response.text
Browse files Browse the repository at this point in the history
Print response text from requests to make debugging easier
  • Loading branch information
fridex committed Mar 1, 2021
2 parents f1e5f13 + 2c3f694 commit 1afe5dd
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
14 changes: 8 additions & 6 deletions features/steps/advise.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ def wait_for_adviser_to_finish(context):
def retrieve_advise_respond(context):
"""Retrieve analysis from Thoth using User API."""
response = requests.get(f"{context.scheme}://{context.user_api_host}/api/v1/advise/python/{context.analysis_id}")
assert (
response.status_code == 200
), f"Bad status code ({response.status_code}) when obtaining adviser result from {context.user_api_host}"
assert response.status_code == 200, (
f"Bad status code ({response.status_code}) when obtaining adviser result from "
f"{context.user_api_host}: {response.text}"
)
context.adviser_result = response.json()


Expand Down Expand Up @@ -194,9 +195,10 @@ def step_impl(context):
response = requests.get(
f"{context.scheme}://{context.user_api_host}/api/v1/advise/python/{context.analysis_id}/log"
)
assert (
response.status_code == 200
), f"Bad status code ({response.status_code}) when obtaining adviser result from {context.user_api_host}"
assert response.status_code == 200, (
f"Bad status code ({response.status_code}) when obtaining adviser result "
f"from {context.user_api_host}: {response.text}"
)

assert "log" in response.json(), f"No log information in the response: {response.json()}"
assert response.json()["log"], "No logs available"
Expand Down
2 changes: 1 addition & 1 deletion features/steps/amun_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def amun_accessible(context, scheme):

assert (
response.status_code == 200
), f"Invalid response when accessing Amun API /api/v1 endpoint: {response.status_code!r}"
), f"Invalid response when accessing Amun API /api/v1 endpoint: {response.status_code!r}: {response.text}"

assert response.text, "Empty response from server for Amun API /api/v1 endpoint"

Expand Down
4 changes: 2 additions & 2 deletions features/steps/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def deployment_accessible(context, scheme):

assert (
response.status_code == 200
), f"Invalid response when accessing User API /api/v1 endpoint: {response.status_code!r}"
), f"Invalid response when accessing User API /api/v1 endpoint: {response.status_code!r}: {response.text}"

assert response.text, "Empty response from server for User API /api/v1 endpoint"

Expand All @@ -49,6 +49,6 @@ def deployment_accessible(context, scheme):

assert (
response.status_code == 200
), f"Invalid response when accessing Management API /api/v1 endpoint: {response.status_code!r}"
), f"Invalid response when accessing Management API /api/v1 endpoint: {response.status_code!r}: {response.text}"

assert response.text, "Empty response from server for Management API /api/v1 endpoint"
7 changes: 4 additions & 3 deletions features/steps/provenance_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ def step_impl(context):
response = requests.get(
f"{context.scheme}://{context.user_api_host}/api/v1/provenance/python/{context.analysis_id}"
)
assert (
response.status_code == 200
), f"Bad status code ({response.status_code}) when obtaining adviser result from {context.user_api_host}"
assert response.status_code == 200, (
f"Bad status code ({response.status_code}) when obtaining adviser "
f"result from {context.user_api_host}: {response.text}"
)
context.provenance_result = response.json()


Expand Down
2 changes: 1 addition & 1 deletion features/steps/python_package_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def step_impl(context, package_name: str, version: str, index: str):

assert (
response.status_code == 200
), f"Bad status code ({response.status_code}) when obtaining dependencies from {url}"
), f"Bad status code ({response.status_code}) when obtaining dependencies from {url}: {response.text}"

context.dependencies = response.json()["dependencies"]

Expand Down
9 changes: 5 additions & 4 deletions features/steps/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ def step_impl(context, package_name, package_version):
params={"secret": context.management_api_secret},
)

assert (
response.status_code == 202
), f"Invalid response when scheduling analysis for the given Python package: {response.status_code!r}"
assert response.status_code == 202, (
f"Invalid response when scheduling analysis for the given "
f"Python package: {response.status_code!r}: {response.text}"
)

context.analysis_id = response.json()["analysis_id"]

Expand All @@ -74,7 +75,7 @@ def step_impl(context):
response = requests.get(url)
assert (
response.status_code == 200
), f"Bad status code ({response.status_code}) when obtaining status for analysis_id {a_i}"
), f"Bad status code ({response.status_code}) when obtaining status for analysis_id {a_i}: {response.text}"
result = response.json()
state = result["status"]["state"]
if state in ["running", "pending"]:
Expand Down

0 comments on commit 1afe5dd

Please sign in to comment.