def _followee_post(self): """ Returns the posted comment. """ self.user.follow(self.actor) comment = create_quest_comment(author=self.actor) stream = ActivityStream(self.user.id, activity_types=[FolloweePostedActivity]) activity = FolloweePostedActivity.from_comment(self.actor, comment) stream.push(activity) return comment
def test_followee_posted(self): self.user.follow(self.actor) comment = create_quest_comment(author=self.actor) stream = ActivityStream(self.user.id, activity_types={FolloweePostedActivity.TYPE: FolloweePostedActivity}) activity = FolloweePostedActivity.from_comment(self.actor, comment) stream.push(activity) activity, _ = list(self.user.redis.activity_stream) self.assertEqual(activity.to_client()['comment_id'], comment.id)
def test_cache_invalidation(self): original_len = len(self._get_items()) self.user.follow(self.actor) comment = create_quest_comment(author=self.actor) stream = ActivityStream(self.user.id, activity_types=[FolloweePostedActivity]) activity = FolloweePostedActivity.from_comment(self.actor, comment) stream.push(activity) self.assertEqual(len(self._get_items()), original_len + 1)
def test_cache_invalidation(self): def get_items(): return self.api_post('/api/activity/activities', user=self.user)['activities'] original_len = len(get_items()) self.user.follow(self.actor) comment = create_quest_comment(author=self.actor) stream = ActivityStream(self.user.id, activity_types={FolloweePostedActivity.TYPE: FolloweePostedActivity}) activity = FolloweePostedActivity.from_comment(self.actor, comment) stream.push(activity) self.assertEqual(len(get_items()), original_len + 1)
def test_followee_posted(self): self.user.follow(self.actor) comment = create_quest_comment(author=self.actor) stream = ActivityStream(self.user.id, activity_types={ FolloweePostedActivity.TYPE: FolloweePostedActivity }) activity = FolloweePostedActivity.from_comment(self.actor, comment) stream.push(activity) activity, _ = list(self.user.redis.activity_stream) self.assertEqual(activity.to_client()['comment_id'], comment.id)
def test_cache_invalidation(self): def get_items(): return self.api_post('/api/activity/activities', user=self.user)['activities'] original_len = len(get_items()) self.user.follow(self.actor) comment = create_quest_comment(author=self.actor) stream = ActivityStream(self.user.id, activity_types={ FolloweePostedActivity.TYPE: FolloweePostedActivity }) activity = FolloweePostedActivity.from_comment(self.actor, comment) stream.push(activity) self.assertEqual(len(get_items()), original_len + 1)
def _action_followee_posted(self, notification): from drawquest.activities import FolloweePostedActivity return FolloweePostedActivity.from_comment(notification.actor, notification.comment)