DDG Definitions' unit tests

This commit is contained in:
Cqoicebordel
2015-02-09 18:28:08 +01:00
parent 0a537d3b89
commit 8c2a5f0492
3 changed files with 254 additions and 2 deletions

View File

@@ -25,9 +25,10 @@ def request(query, params):
def response(resp):
search_res = json.loads(resp.text)
results = []
search_res = json.loads(resp.text)
content = ''
heading = search_res.get('Heading', '')
attributes = []
@@ -68,7 +69,7 @@ def response(resp):
results.append({'title': heading, 'url': firstURL})
# related topics
for ddg_result in search_res.get('RelatedTopics', None):
for ddg_result in search_res.get('RelatedTopics', []):
if 'FirstURL' in ddg_result:
suggestion = result_to_text(ddg_result.get('FirstURL', None),
ddg_result.get('Text', None),