示例#1
0
def test_content_type():
    responses.add(responses.GET,
                  'http://mock/test',
                  body='{"test": True}',
                  status=502,
                  content_type=None)

    r = requests.get('http://mock/test')

    data = Interface(None).get_data(r)
    assert data is None
示例#2
0
def test_client_error():
    responses.add(responses.GET,
                  'http://mock/test',
                  body='{"test": True}',
                  status=404,
                  content_type=None)

    r = requests.get('http://mock/test')

    with pytest.raises(exceptions.ClientError):
        Interface(None).get_data(r, exceptions=True)
示例#3
0
def test_client_error():
    with HTTMock(client_error):
        response = requests.get('http://mock/test')

    with pytest.raises(exceptions.ClientError):
        Interface(None).get_data(response, exceptions=True)
示例#4
0
def test_missing_content_type():
    with HTTMock(server_error):
        response = requests.get('http://mock/test')

    data = Interface(None).get_data(response)
    assert data is None