Exemplo n.º 1
0
def test_response_and_message_and_swagger_result(response_500):
    incoming_response = RequestsResponseAdapter(response_500)
    actual = str(
        HTTPError(incoming_response,
                  message="Holy moly!",
                  swagger_result={'msg': 'Kaboom'}))
    assert actual == "500 Server Error: Holy moly!: {'msg': 'Kaboom'}"
Exemplo n.º 2
0
def test_make_http_exception_unknown():
    requests_response = Response()
    requests_response.status_code = 600
    requests_response.reason = "Womp Error"
    exc = make_http_exception(
        RequestsResponseAdapter(requests_response),
    )
    assert type(exc) == HTTPError
Exemplo n.º 3
0
def test_make_http_exception(response_500):
    incoming_response = RequestsResponseAdapter(response_500)
    exc = make_http_exception(incoming_response,
                              message="Holy moly!",
                              swagger_result={'msg': 'Kaboom'})
    assert isinstance(exc, HTTPError)
    assert isinstance(exc, HTTPServerError)
    assert type(exc) == HTTPInternalServerError
    assert str(exc) == "500 Server Error: Holy moly!: {'msg': 'Kaboom'}"
Exemplo n.º 4
0
def test_http_error(mock_get_paasta_api_client):
    args = mock.Mock()
    args.cluster = "westeros-prod"

    mock_response = mock.Mock(status_code=500, text="Internal Server Error")
    response_adapter = RequestsResponseAdapter(mock_response)

    mock_api_client = mock_get_paasta_api_client.return_value
    mock_api_client.deploy_queue.deploy_queue.return_value.result.side_effect = HTTPError(
        response_adapter
    )

    assert list_deploy_queue(args) == 500
Exemplo n.º 5
0
def test_paasta_status_exception(system_paasta_config):
    system_paasta_config = system_paasta_config

    with mock.patch('paasta_tools.cli.cmds.status.get_paasta_api_client',
                    autospec=True) as mock_get_paasta_api_client:
        requests_response = mock.Mock(status_code=500,
                                      reason='Internal Server Error')
        incoming_response = RequestsResponseAdapter(requests_response)

        mock_swagger_client = mock.Mock()
        mock_swagger_client.service.status_instance.side_effect = HTTPError(
            incoming_response)
        mock_get_paasta_api_client.return_value = mock_swagger_client
        paasta_status_on_api_endpoint(
            'fake_cluster',
            'fake_service',
            'fake_instance',
            system_paasta_config,
            verbose=False,
        )
Exemplo n.º 6
0
def test_make_http_exception_type(status_code, expected_type):
    requests_response = Response()
    requests_response.status_code = status_code
    requests_response.reason = "Womp Error"
    exc = make_http_exception(RequestsResponseAdapter(requests_response), )
    assert type(exc) == expected_type
Exemplo n.º 7
0
def test_response_and_message(response_500):
    incoming_response = RequestsResponseAdapter(response_500)
    actual = str(HTTPError(incoming_response, message="Kaboom"))
    assert actual == '500 Server Error: Kaboom'
Exemplo n.º 8
0
def test_response_only(response_500):
    incoming_response = RequestsResponseAdapter(response_500)
    assert str(HTTPError(incoming_response)) == '500 Server Error'