mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add tests for new date range and history filtering as well as to ensure only admins get to see external_id and command_line and that users cannot see each other's jobs. Always allow admins to views all jobs on index (instead of only when user_details is specified) and show. Add user_email and external_id to show (for admins) to bring it inline with index and add command_line to index (for admins) to bring it in line with show. Show still allow more details including job standard error and output as well as job metrics.
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
""" Utility methods for making assertions about Galaxy API responses, etc...
|
|
"""
|
|
ASSERT_FAIL_ERROR_CODE = "Expected Galaxy error code %d, obtained %d"
|
|
ASSERT_FAIL_STATUS_CODE = "Request status code (%d) was not expected value %d. Body was %s"
|
|
|
|
|
|
def assert_status_code_is( response, expected_status_code ):
|
|
response_status_code = response.status_code
|
|
if expected_status_code != response_status_code:
|
|
try:
|
|
body = response.json()
|
|
except Exception:
|
|
body = "INVALID JSON RESPONSE <%s>" % response.content
|
|
assertion_message = ASSERT_FAIL_STATUS_CODE % ( response_status_code, expected_status_code, body )
|
|
raise AssertionError( assertion_message )
|
|
|
|
|
|
def assert_has_keys( response, *keys ):
|
|
for key in keys:
|
|
assert key in response, "Response [%s] does not contain key [%s]" % ( response, key )
|
|
|
|
|
|
def assert_not_has_keys( response, *keys ):
|
|
for key in keys:
|
|
assert key not in response, "Response [%s] contains invalid key [%s]" % ( response, key )
|
|
|
|
|
|
def assert_error_code_is( response, error_code ):
|
|
if hasattr( response, "json" ):
|
|
response = response.json()
|
|
assert_has_keys( response, "err_code" )
|
|
err_code = response[ "err_code" ]
|
|
assert err_code == int( error_code ), ASSERT_FAIL_ERROR_CODE % ( err_code, int( error_code ) )
|
|
|
|
assert_has_key = assert_has_keys
|