forked from Logic-gate/fullcontact.py
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add convenience method for each GET endpoint
- Loading branch information
Showing
3 changed files
with
17 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ Usage | |
>>> fc = FullContact('your_api_key') | ||
|
||
# returns a real requests object | ||
>>> r = fc.api_get('person', **{'email': '[email protected]'}) | ||
>>> r = fc.person(email='[email protected]') | ||
>>> r.status_code | ||
200 | ||
>>> r.headers['x-rate-limit-remaining'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
from types import FunctionType | ||
from fullcontact import FullContact | ||
from nose.tools import assert_equal | ||
from nose.tools import assert_equal, assert_true | ||
|
||
|
||
class TestFullContact(object): | ||
def test_trivial_pass(self): | ||
assert_equal(1, 1) | ||
|
||
def test_init(self): | ||
fc = FullContact('') | ||
assert_equal(fc.api_key, '') | ||
fc = FullContact('test_key') | ||
assert_equal(fc.api_key, 'test_key') | ||
|
||
def test__prepare_batch_url(self): | ||
fc = FullContact('') | ||
fc = FullContact('test_key') | ||
assert_equal( | ||
fc._prepare_batch_url(('person', {'email': '[email protected]'})), | ||
'https://api.fullcontact.com/v2/person.json?email=test%40test.com' | ||
) | ||
|
||
def test_invalid_api_keys(self): | ||
fc = FullContact('') | ||
r = fc.api_get('person', **{'email': '[email protected]'}) | ||
fc = FullContact('test_key') | ||
r = fc.person(email='[email protected]') | ||
assert_equal(r.status_code, 403) | ||
|
||
test_batch = [ | ||
|
@@ -29,3 +27,8 @@ def test_invalid_api_keys(self): | |
|
||
r = fc.api_batch(test_batch) | ||
assert_equal(r.status_code, 403) | ||
|
||
def test_adds_endpoint_methods(self): | ||
fc = FullContact('') | ||
for endpoint in fc.get_endpoints: | ||
assert_true(isinstance(getattr(fc, endpoint), FunctionType)) |