示例#1
0
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):
        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):
        api.handle_response(mocked_response)

    mocked_response.status_code = 1001
    with pytest.raises(exceptions.ConnectionError):
        api.handle_response(mocked_response)
示例#2
0
def test_handle_request(mocked_response):
    api = Api()

    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):
        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):
        api.handle_response(mocked_response)

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