Esempio n. 1
0
def test_validate_response_not_found_error(response_kwargs):
    status_code = status.HTTP_404_NOT_FOUND
    response = Response(**response_kwargs, status_code=status_code)
    with pytest.raises(NotFoundError) as excinfo:
        validate_response(response)
    assert excinfo.value.response.status_code == status_code
    assert "operation=not_found_error" in str(excinfo.value)
def test_validate_response_client_error(status_code):
    response = Response(
        url='http://example.com', method='GET', body=None, headers={},
        status_code=status_code, client_response=mock.Mock()
    )
    with pytest.raises(ClientError) as excinfo:
        validate_response(response)
    assert excinfo.value.response.status_code == status_code
    assert 'operation=client_error' in str(excinfo.value)
Esempio n. 3
0
def test_validate_response_client_error(status_code, response_kwargs):
    response = Response(**response_kwargs, status_code=status_code)
    with pytest.raises(ClientError) as excinfo:
        validate_response(response)
    assert excinfo.value.response.status_code == status_code
    assert "operation=client_error" in str(excinfo.value)
Esempio n. 4
0
def test_validate_response_auth_error(status_code, response_kwargs):
    response = Response(**response_kwargs, status_code=status_code)
    with pytest.raises(AuthError) as excinfo:
        validate_response(response)
    assert excinfo.value.response.status_code == status_code
    assert 'operation=auth_error' in str(excinfo.value)