예제 #1
0
def test_request_api__unable_to_connect(mock_get):
    mock_get.side_effect = requests.exceptions.ConnectionError()
    pp = Peri()

    with pytest.raises(PyPeriConnectionError):
        pp.request_api('testEndpoint',
                       test_param='something',
                       test_param2='else')
예제 #2
0
def test_request_api():
    mock_url = ('https://api.periscope.tv/api/v2/testEndpoint?'
                'test_param=something&test_param2=else')
    mock_body = '{"test":"ok"}'
    httpretty.register_uri(httpretty.GET, mock_url, mock_body)
    pp = Peri()
    result = pp.request_api('testEndpoint',
                            test_param='something',
                            test_param2='else')
    assert result == {'test': 'ok'}
예제 #3
0
def test_request_api__not_founds():
    mock_url = ('https://api.periscope.tv/api/v2/testEndpoint?'
                'test_param=something&test_param2=else')
    mock_body = '{"some":"test"}'
    status_code = 404
    httpretty.register_uri(httpretty.GET,
                           mock_url,
                           mock_body,
                           status=status_code)
    pp = Peri()
    result = pp.request_api('testEndpoint',
                            test_param='something',
                            test_param2='else')
    assert result is None