Skip to content

Commit

Permalink
[#1631] Add tests for group_activity_list() logic function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hammond committed Jan 16, 2012
1 parent 879936b commit 7c5ad44
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ckan/tests/models/test_activity.py
Expand Up @@ -77,6 +77,12 @@ def get_package_activity_stream(package_id):
data_dict = {'id':package_id}
return package_activity_list(context, data_dict)

def get_group_activity_stream(group_id):
'''Return the public activity stream for the given group.'''
context = {'model':model}
data_dict = {'id':group_id}
return group_activity_list(context, data_dict)

def get_user_activity_stream_from_api(user_id):
'''
Return the public activity stream for the given user, but get it via the
Expand Down Expand Up @@ -786,6 +792,10 @@ def test_create_group(self):
"the user's activity stream, but found %i" % len(new_activities))
activity = new_activities[0]

assert (get_group_activity_stream(group_created['id']) ==
new_activities), ("The same activity should also appear in the "
"group's activity stream.")

# Check that the new activity has the right attributes.
assert activity['object_id'] == group_created['id'], \
str(activity['object_id'])
Expand Down Expand Up @@ -813,7 +823,7 @@ def _update_group(self, group, user):
context = {'model': model, 'session': model.Session, 'user': user.name,
'allow_partial_update': True}
group_dict = {'id': group.id, 'title': 'edited'}
group_update(context, group_dict)
group_updated = group_update(context, group_dict)

after = record_details(user.id)

Expand All @@ -824,6 +834,10 @@ def _update_group(self, group, user):
"the user's activity stream, but found %i" % len(new_activities))
activity = new_activities[0]

assert (get_group_activity_stream(group_updated['id']) ==
new_activities), ("The same activity should also appear in the "
"group's activity stream.")

# Check that the new activity has the right attributes.
assert activity['object_id'] == group.id, str(activity['object_id'])
assert activity['user_id'] == user.id, str(activity['user_id'])
Expand Down

0 comments on commit 7c5ad44

Please sign in to comment.