Helper functions for tests using REST API.
assert_response(rest_obj, success=None, http_status=None, results_num=None, task_wait=600)¶
Asserts that the response HTTP status code and content is as expected.
If specific http_status is not given, we simply check that the status was a successful response code via requests.Response.__bool__()
If response status code is ‘204’, ensures there is no content.
Example of verifying a success response:
Example of verifying a failure response:
with error.expected('ActiveRecord::RecordNotFound'): collection.action.delete(some_stuff) assert_response(appliance, http_status=404)
Note: For below args, ‘results’ refers to rest_obj.last_response.json()[‘results’]
- -- instance of cfme.utils.Appliance (rest_obj) – or cfme.utils.appliance.MiqApi
- -- if defined, checks each result in results to ensure that result['success'] (success) – is equal to the value defined here
- http_status (int or tuple of int) – we simply verify that the response was a success
- results_num (int) –
- task_wait (int) – the API to ensure that task has moved to ‘finished’ and wait ‘task_wait’ seconds for that state change to occur
create_resource(rest_api, col_name, col_data, col_action='create', substr_search=False)¶
Creates new resource in collection.
delete_resources_from_collection(resources, collection=None, not_found=None, num_sec=10, delay=2, check_response=True)¶
Checks that delete from collection works as expected.
delete_resources_from_detail(resources, method='POST', num_sec=10, delay=2, check_response=True)¶
Checks that delete from detail works as expected.
Gets list of vm entities associated with the service.
Checks that all available attributes/subcollections are really accessible.