def test_base_class_can_use_post(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()
        req.base_url = 'http://www.foo.com/'
        response = req._post('/', data=[])
        assert response.status_code == 200
        assert response.json() == dict(status_code=200, result=dict(foo='bar'))
def test_base_class_can_use_post(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()
        req.base_url = 'http://www.foo.com/'
        response = req._post('/', data=[])
        assert response.status_code == 200
        assert response.json() == dict(status_code=200, result=dict(foo='bar'))
def test_base_request_post():
    from cloudelements import BaseRequest
    httpretty.register_uri(
        httpretty.POST,
        '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._post('v1/emailguess/job/status/1', data=dict(foo='bar'))
    assert resp.json() == dict(foo='bar', baz=2)
def test_base_request_post():
    from cloudelements import BaseRequest
    httpretty.register_uri(
        httpretty.POST,
        '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._post('v1/emailguess/job/status/1', data=dict(foo='bar'))
    assert resp.json() == dict(foo='bar', baz=2)