Skip to content

Commit

Permalink
[#316] Update some more activity streams tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hammond committed Jan 30, 2013
1 parent 9992083 commit 7ea77f0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
40 changes: 22 additions & 18 deletions ckan/tests/functional/api/test_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2017,32 +2017,36 @@ def test_follow_dataset(self):
# Find the new activity in the user's activity stream.
user_new_activities = (find_new_activities(
before['user activity stream'], after['user activity stream']))
assert len(user_new_activities) == 1, ("There should be 1 new "
assert len(user_new_activities) == 0, ("There should be 0 new "
" activity in the user's activity stream, but found %i" %
len(user_new_activities))
activity = user_new_activities[0]

# The rest of this test is commented out because 'follow dataset'
# activities are disabled, even they are reenabled then uncomment it.

#activity = user_new_activities[0]

# The same new activity should appear in the package's activity stream.
pkg_new_activities = after['package activity stream']
for activity in user_new_activities:
assert activity in pkg_new_activities
#pkg_new_activities = after['package activity stream']
#for activity in user_new_activities:
# assert activity in pkg_new_activities

# Check that the new activity has the right attributes.
assert activity['object_id'] == self.warandpeace['id'], \
str(activity['object_id'])
assert activity['user_id'] == user['id'], str(activity['user_id'])
assert activity['activity_type'] == 'follow dataset', \
str(activity['activity_type'])
if 'id' not in activity:
assert False, "activity object should have an id value"
#assert activity['object_id'] == self.warandpeace['id'], \
# str(activity['object_id'])
#assert activity['user_id'] == user['id'], str(activity['user_id'])
#assert activity['activity_type'] == 'follow dataset', \
# str(activity['activity_type'])
#if 'id' not in activity:
# assert False, "activity object should have an id value"
# TODO: Test for the _correct_ revision_id value.
if 'revision_id' not in activity:
assert False, "activity object should have a revision_id value"
timestamp = datetime_from_string(activity['timestamp'])
assert timestamp >= before['time'] and timestamp <= \
after['time'], str(activity['timestamp'])
#if 'revision_id' not in activity:
# assert False, "activity object should have a revision_id value"
#timestamp = datetime_from_string(activity['timestamp'])
#assert timestamp >= before['time'] and timestamp <= \
# after['time'], str(activity['timestamp'])

assert len(self.activity_details(activity)) == 0
#assert len(self.activity_details(activity)) == 0

def test_follow_user(self):
user = self.normal_user
Expand Down
2 changes: 1 addition & 1 deletion ckan/tests/functional/test_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_user_activity(self):
result = self.app.get(offset, status=200)
stripped = self.strip_tags(result)
assert '%s started following %s' % (user['fullname'],
package['title']) in stripped, stripped
package['title']) not in stripped, stripped

# Follow another user.
follow_user(context, {'id': 'joeadmin'})
Expand Down

0 comments on commit 7ea77f0

Please sign in to comment.