Skip to content

Commit

Permalink
Seach results method and add auth_token to search requests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljoseph committed Jul 12, 2012
1 parent bba9b3e commit e19b36d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
14 changes: 13 additions & 1 deletion authoritarian/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def search(keyword, engine, locale, immediate=False):
}[immediate],

data={
'auth_token': config['api_key'],
'keyword': keyword,
'engine': engine,
'locale': locale,
Expand All @@ -39,4 +40,15 @@ def search(keyword, engine, locale, immediate=False):


def results(keyword, engine, locale, rank_date):
pass
response = requests.get(BASE + '/keywords/get.json',
params={
'auth_token': config['api_key'],
'keyword': keyword,
'response_format': 'json',
'engine': engine,
'locale': locale,
'rank_date': rank_date,
}
)
if response.ok:
return response.json
17 changes: 16 additions & 1 deletion tests/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def test_search_delayed(self):
self.requests.post.assert_called_once_with(
'http://api.authoritylabs.com/keywords',
data={
'auth_token': 'api-key',
'keyword': 'your country needs you',
'engine': 'google',
'locale': 'en-us',
Expand All @@ -55,10 +56,24 @@ def test_search_immediate(self):
self.requests.post.assert_called_once_with(
'http://api.authoritylabs.com/keywords/priority',
data={
'auth_token': 'api-key',
'keyword': 'your country needs you',
'engine': 'google',
'locale': 'en-us',
}
)
def test_results(self):
pass
authoritarian.initialise('api-key')
authoritarian.results('your country needs you', 'google',
'en-us', '2012-07-12')
self.requests.get.assert_called_once_with(
'http://api.authoritylabs.com/keywords/get.json',
params={
'auth_token': 'api-key',
'keyword': 'your country needs you',
'response_format': 'json',
'engine': 'google',
'locale': 'en-us',
'rank_date': '2012-07-12',
}
)

0 comments on commit e19b36d

Please sign in to comment.