How to use the mkmsdk.exceptions.ConnectionError function in mkmsdk

To help you get started, we’ve selected a few mkmsdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github evonove / mkm-sdk / tests / tests_unit / test_exception.py View on Github external
def test_connection_error_with_message():
    """
    Test error string is formatted correctly
    when exception is initialized with a message
    """
    error = ConnectionError(message="This is a message")

    assert str(error) == "Request failed\nThis is a message"
github evonove / mkm-sdk / tests / tests_unit / test_api.py View on Github external
def test_handle_request(mocked_response):
    api = Api("https://sandbox.cardmarket.com/ws/v1.1/output.json")

    mocked_response.status_code = 400
    with pytest.raises(exceptions.ConnectionError):
        api.handle_response(mocked_response)

    mocked_response.status_code = 401
    with pytest.raises(exceptions.ConnectionError):
        api.handle_response(mocked_response)

    mocked_response.status_code = 403
    with pytest.raises(exceptions.ConnectionError):
        api.handle_response(mocked_response)

    mocked_response.status_code = 404
    with pytest.raises(exceptions.ConnectionError):
        api.handle_response(mocked_response)

    mocked_response.status_code = 405
    with pytest.raises(exceptions.ConnectionError):
github evonove / mkm-sdk / tests / tests_unit / test_api.py View on Github external
api.handle_response(mocked_response)

    mocked_response.status_code = 403
    with pytest.raises(exceptions.ConnectionError):
        api.handle_response(mocked_response)

    mocked_response.status_code = 404
    with pytest.raises(exceptions.ConnectionError):
        api.handle_response(mocked_response)

    mocked_response.status_code = 405
    with pytest.raises(exceptions.ConnectionError):
        api.handle_response(mocked_response)

    mocked_response.status_code = 409
    with pytest.raises(exceptions.ConnectionError):
        api.handle_response(mocked_response)

    mocked_response.status_code = 410
    with pytest.raises(exceptions.ConnectionError):
        api.handle_response(mocked_response)

    mocked_response.status_code = 422
    with pytest.raises(exceptions.ConnectionError):
        api.handle_response(mocked_response)

    mocked_response.status_code = 480
    with pytest.raises(exceptions.ConnectionError):
        api.handle_response(mocked_response)

    mocked_response.status_code = 545
    with pytest.raises(exceptions.ConnectionError):
github evonove / mkm-sdk / tests / tests_unit / test_exception.py View on Github external
def test_connection_error_with_empty_response():
    """
    Test error string is formatted correctly
    when exception is initialized with empty response
    """
    error = ConnectionError({})

    assert str(error) == "Request failed"
github evonove / mkm-sdk / tests / tests_unit / test_exception.py View on Github external
def test_connection_error_with_no_args():
    """
    Test error string is formatted correctly
    when exception is initialized without arguments
    """
    error = ConnectionError()

    assert str(error) == "Request failed"
github evonove / mkm-sdk / tests / tests_unit / test_exception.py View on Github external
def test_connection_error_with_response():
    """
    Test error string is formatted correctly
    when exception is initialized with response
    """
    Response = namedtuple("Response", "status_code reason content")
    response = Response(status_code="404", reason="Not found", content="Here some content")
    error = ConnectionError(response)

    assert str(error) == "Request failed\nStatus code: 404\nResponse message: Not found\nHere some content"