コード例 #1
0
def test_base_class_can_use_methods(mock_get):
    from cloudelements import BaseRequest
    with patch('cloudelements.requests.Response') as mock_response:
        mock_response = MockResponse()
        mock_get.return_value = mock_response
        req = BaseRequest(base_url='http://www.foo.com/')
        response = req._get('/', params=dict(foo='bar'))
        assert response.status_code == 200
        assert response.json() == dict(status_code=200, result=dict(foo='bar'))
コード例 #2
0
def test_base_class_can_use_methods(mock_get):
    from cloudelements import BaseRequest
    with patch('cloudelements.requests.Response') as mock_response:
        mock_response = MockResponse()
        mock_get.return_value = mock_response
        req = BaseRequest(base_url='http://www.foo.com/')
        response = req._get('/', params=dict(foo='bar'))
        assert response.status_code == 200
        assert response.json() == dict(status_code=200, result=dict(foo='bar'))
コード例 #3
0
def test_base_request_get_with_params():
    from cloudelements import BaseRequest
    httpretty.register_uri(
        httpretty.GET,
        'http://api.leadgenius.com/v1/emailguess/job/status/1',
        body='{ "foo": "bar", "baz": 2}',
        content_type="application/json")

    req = BaseRequest('http://api.leadgenius.com/')
    resp = req._get('v1/emailguess/job/status/1', params=dict(foo='bar'))
    assert resp.json() == dict(foo='bar', baz=2)
コード例 #4
0
def test_base_request_get_with_params():
    from cloudelements import BaseRequest
    httpretty.register_uri(
        httpretty.GET,
        'http://api.leadgenius.com/v1/emailguess/job/status/1',
        body='{ "foo": "bar", "baz": 2}',
        content_type="application/json"
    )

    req = BaseRequest('http://api.leadgenius.com/')
    resp = req._get('v1/emailguess/job/status/1', params=dict(foo='bar'))
    assert resp.json() == dict(foo='bar', baz=2)
コード例 #5
0
def test_base_request_get_with_auth_token():
    from cloudelements import BaseRequest
    httpretty.register_uri(
        httpretty.GET,
        'http://api.leadgenius.com/v1/emailguess/job/status/1',
        body='{ "foo": "bar", "baz": 2}',
        content_type="application/json",
        status=200)

    req = BaseRequest('http://api.leadgenius.com/')
    resp = req._get('v1/emailguess/job/status/1', auth_token='adsfasdf')
    assert resp.status_code == 200
    assert resp.json() == dict(foo='bar', baz=2)
コード例 #6
0
def test_base_request_get_with_auth_token():
    from cloudelements import BaseRequest
    httpretty.register_uri(
        httpretty.GET,
        'http://api.leadgenius.com/v1/emailguess/job/status/1',
        body='{ "foo": "bar", "baz": 2}',
        content_type="application/json",
        status=200
    )

    req = BaseRequest('http://api.leadgenius.com/')
    resp = req._get('v1/emailguess/job/status/1', auth_token='adsfasdf')
    assert resp.status_code == 200
    assert resp.json() == dict(foo='bar', baz=2)