Skip to content

Commit

Permalink
Use f-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Mar 9, 2024
1 parent 92f23aa commit 68b5cf4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/galaxy_test/base/api_asserts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@

from galaxy.exceptions.error_codes import ErrorCode

ASSERT_FAIL_ERROR_CODE = "Expected Galaxy error code %d, obtained %d"
ASSERT_FAIL_STATUS_CODE = "Request status code (%d) was not expected value %s. Body was %s"


def assert_status_code_is(response: Response, expected_status_code: int, failure_message: Optional[str] = None):
"""Assert that the supplied response has the expect status code."""
Expand Down Expand Up @@ -45,7 +42,9 @@ def _report_status_code_error(
body = response.json()
except Exception:
body = f"INVALID JSON RESPONSE <{response.text}>"
assertion_message = ASSERT_FAIL_STATUS_CODE % (response.status_code, expected_status_code, body)
assertion_message = (
f"Request status code ({response.status_code}) was not expected value {expected_status_code}. Body was {body}"
)
if failure_message:
assertion_message = f"{failure_message}. {assertion_message}"
raise AssertionError(assertion_message)
Expand All @@ -72,7 +71,7 @@ def assert_error_code_is(response: Union[Response, dict], error_code: Union[int,
as_dict = _as_dict(response)
assert_has_keys(as_dict, "err_code")
err_code = as_dict["err_code"]
assert err_code == int(error_code), ASSERT_FAIL_ERROR_CODE % (error_code, err_code)
assert err_code == int(error_code), f"Expected Galaxy error code {error_code}, obtained {err_code}"


def assert_object_id_error(response: Response):
Expand Down

0 comments on commit 68b5cf4

Please sign in to comment.