Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion constructor_io/modules/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_all_tasks(self, parameters=None):
json = response.json()

if json:
if json.get('total_count'):
if json.get('total_count') is not None:
return json

raise ConstructorException('get_all_tasks response data is malformed')
Expand Down
2 changes: 1 addition & 1 deletion tests/modules/test_autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def test_with_no_query():
def test_with_invalid_num_results():
'''Should raise exception when invalid num_results parameter is provided'''

with raises(HttpException, match=r'num_results must be an integer'):
with raises(HttpException, match=r'num_results: value is not a valid integer'):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to this story but I wanted to fix it since it's broken on master

autocomplete = ConstructorIO(VALID_OPTIONS).autocomplete
autocomplete.get_autocomplete_results(QUERY, { 'num_results': 'abc' })

Expand Down
12 changes: 12 additions & 0 deletions tests/modules/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ def test_get_all_tasks_with_type():
assert isinstance(response.get('total_count'), int)
assert len(response.get('tasks')) <= 50 and len(response.get('tasks')) >= 1

def test_get_all_tasks_with_zero_tasks():
'''Should return a valid response when there are zero tasks'''

past_end_date = '2000-01-01'
tasks = ConstructorIO(VALID_OPTIONS).tasks
response = tasks.get_all_tasks({ 'end_date': past_end_date })

assert isinstance(response.get('status_counts'), dict)
assert isinstance(response.get('tasks'), list)
assert isinstance(response.get('total_count'), int)
assert len(response.get('tasks')) == 0

def test_get_all_tasks_with_invalid_api_key():
'''Should raise exception when invalid api_key is provided'''

Expand Down