Skip to content

Commit

Permalink
[#3028] Add some followee tests
Browse files Browse the repository at this point in the history
Add some tests for the followee_count and followee_list actions, mainly
testing the validation
  • Loading branch information
Sean Hammond committed Jan 18, 2013
1 parent 5d3d032 commit 9a56016
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions ckan/tests/functional/api/test_follow.py
Expand Up @@ -436,6 +436,57 @@ def test_04_group_follower_count_no_followers(self):
'group_follower_count', id=self.davids_group['id'])
assert follower_count == 0

def _followee_count_bad_id(self, action):
for object_id in ('bad id', ' ', 3, 35.7, 'xxx', ''):
error = ckan.tests.call_action_api(self.app, action,
status=409, id=object_id)
assert 'id' in error

def test_04_followee_count_bad_id(self):
self._followee_count_bad_id('followee_count')

def test_04_user_followee_count_bad_id(self):
self._followee_count_bad_id('user_followee_count')

def test_04_dataset_followee_count_bad_id(self):
self._followee_count_bad_id('dataset_followee_count')

def test_04_group_followee_count_bad_id(self):
self._followee_count_bad_id('group_followee_count')

def _followee_count_missing_id(self, action):
error = ckan.tests.call_action_api(self.app, action, status=409)
assert error['id'] == ['Missing value']

def test_04_followee_count_missing_id(self):
self._followee_count_missing_id('followee_count')

def test_04_user_followee_count_missing_id(self):
self._followee_count_missing_id('user_followee_count')

def test_04_dataset_followee_count_missing_id(self):
self._followee_count_missing_id('dataset_followee_count')

def test_04_group_followee_count_missing_id(self):
self._followee_count_missing_id('group_followee_count')

def _followee_count_not_following_anything(self, action):
followee_count = ckan.tests.call_action_api(self.app, action,
id=self.russianfan['id'])
assert followee_count == 0

def test_04_followee_count_not_following_anything(self):
self._followee_count_not_following_anything('followee_count')

def test_04_user_followee_count_not_following_anything(self):
self._followee_count_not_following_anything('user_followee_count')

def test_04_dataset_followee_count_not_following_anything(self):
self._followee_count_not_following_anything('dataset_followee_count')

def test_04_group_followee_count_not_following_anything(self):
self._followee_count_not_following_anything('group_followee_count')

def test_04_follower_list_bad_id(self):
for action in ('user_follower_list', 'dataset_follower_list',
'group_follower_list'):
Expand Down Expand Up @@ -465,6 +516,57 @@ def test_04_group_follower_list_no_followers(self):
id=self.davids_group['id'])
assert followers == []

def _followee_list_bad_id(self, action):
for object_id in ('bad id', ' ', 3, 35.7, 'xxx', ''):
error = ckan.tests.call_action_api(self.app, action,
status=409, id=object_id)
assert error['id']

def test_04_followee_list_bad_id(self):
self._followee_list_bad_id('followee_list')

def test_04_user_followee_list_bad_id(self):
self._followee_list_bad_id('user_followee_list')

def test_04_dataset_followee_list_bad_id(self):
self._followee_list_bad_id('dataset_followee_list')

def test_04_group_followee_list_bad_id(self):
self._followee_list_bad_id('group_followee_list')

def _followee_list_missing_id(self, action):
error = ckan.tests.call_action_api(self.app, action, status=409)
assert error['id'] == ['Missing value']

def test_04_followee_list_missing_id(self):
self._followee_list_missing_id('followee_list')

def test_04_user_followee_list_missing_id(self):
self._followee_list_missing_id('user_followee_list')

def test_04_dataset_followee_missing_bad_id(self):
self._followee_list_missing_id('dataset_followee_list')

def test_04_group_followee_missing_bad_id(self):
self._followee_list_missing_id('group_followee_list')

def _followee_list_not_following_anything(self, action):
followees = ckan.tests.call_action_api(self.app, action,
id=self.russianfan['id'])
assert followees == []

def test_04_followee_list_not_following_anything(self):
self._followee_list_not_following_anything('followee_list')

def test_04_user_followee_list_not_following_anything(self):
self._followee_list_not_following_anything('user_followee_list')

def test_04_dataset_followee_not_following_anything(self):
self._followee_list_not_following_anything('dataset_followee_list')

def test_04_group_followee_not_following_anything(self):
self._followee_list_not_following_anything('group_followee_list')

def test_04_am_following_bad_id(self):
for action in ('am_following_dataset', 'am_following_user',
'am_following_group'):
Expand Down

0 comments on commit 9a56016

Please sign in to comment.