Beispiel #1
0
def assert_error_code_error(response, expected_error_code=None, expected_fault_element=None):

    """Method to assert response errors from Policy Manger
    :param response: Response obtained from thelett API REST request to the Policy Manager
    :param expected_fault_element: Expected Fault element in the JSON response
    :param expected_error_code: Expected Error code in the JSON response
    """

    assert_equals(expected_error_code, str(response.status_code),
                  ERROR_CODE_ERROR.format(expected_error_code, str(response.status_code)))
    response_body = response.json()
    assert_in(expected_fault_element, response_body.keys(),
              FAULT_ELEMENT_ERROR.format(expected_fault_element, response_body))
    assert_equals(str(response_body[expected_fault_element]['code']), expected_error_code,
                  ERROR_CODE_ERROR.format(expected_error_code, response_body[expected_fault_element]['code']))
Beispiel #2
0
def assert_rule_is_deleted(context):

    assert_true(context.req.ok, HTTP_CODE_NOT_OK.format(context.req.status_code, context.req.content))

    req = api_utils.retrieve_rule(tenant_id=context.tenant_id, server_id=context.server_id, rule_id=context.rule_id,
                                  headers=context.headers)

    assert_equals(req.status_code, 404, ERROR_CODE_ERROR.format(req.status_code, 404))
Beispiel #3
0
def assert_rule_is_deleted(step):

    assert_true(
        world.req.ok,
        HTTP_CODE_NOT_OK.format(world.req.status_code, world.req.content))
    req = api_utils.retrieve_rule(tenant_id=world.tenant_id,
                                  server_id=world.server_id,
                                  rule_id=world.rule_id,
                                  headers=world.headers)
    assert_equals(req.status_code, 404,
                  ERROR_CODE_ERROR.format(req.status_code, 404))
Beispiel #4
0
def assert_error_code_error(response,
                            expected_error_code=None,
                            expected_fault_element=None):
    """Method to assert response errors from Policy Manger
    :param response: Response obtained from thelett API REST request to the Policy Manager
    :param expected_fault_element: Expected Fault element in the JSON response
    :param expected_error_code: Expected Error code in the JSON response
    """

    assert_equals(
        expected_error_code, str(response.status_code),
        ERROR_CODE_ERROR.format(expected_error_code,
                                str(response.status_code)))
    response_body = response.json()
    assert_in(
        expected_fault_element, response_body.keys(),
        FAULT_ELEMENT_ERROR.format(expected_fault_element, response_body))
    assert_equals(
        str(response_body[expected_fault_element]['code']),
        expected_error_code,
        ERROR_CODE_ERROR.format(expected_error_code,
                                response_body[expected_fault_element]['code']))