def test_dispatch_action(self): from ..models import (follow, unfollow) from .sequere_registry import JoinAction, LikeAction, Project from sequere.contrib.timeline import Timeline follow(self.newbie, self.user) timeline = Timeline(self.user) action = JoinAction(self.user) timeline.save(action) timeline = Timeline(self.newbie) self.assertEqual(timeline.get_private_count(), 1) self.assertEqual(timeline.get_public_count(), 0) unfollow(self.newbie, self.user) action = LikeAction(actor=self.user, target=self.project) timeline = Timeline(self.user) timeline.save(action) self.assertEqual(timeline.get_private_count(), 2) self.assertEqual(timeline.get_public_count(), 2) self.assertEqual(timeline.get_private_count(target=Project), 1) self.assertEqual(timeline.get_public_count(target=Project), 1) timeline = Timeline(self.newbie) self.assertEqual(timeline.get_private_count(), 0) self.assertEqual(timeline.get_unread_count(), 0) timeline.mark_as_read(timestamp=datetime.now() + timedelta(days=1)) self.assertEqual(timeline.get_unread_count(), 0) self.assertEqual(timeline.get_public_count(), 0)
def test_dispatch_action(self): from ..models import (follow, unfollow) from .sequere_registry import JoinAction, LikeAction, Project from sequere.contrib.timeline import Timeline follow(self.newbie, self.user) timeline = Timeline(self.user) action = JoinAction(self.user) timeline.save(action) timeline = Timeline(self.newbie) self.assertEqual(timeline.get_private_count(), 1) self.assertEqual(timeline.get_public_count(), 0) unfollow(self.newbie, self.user) action = LikeAction(actor=self.user, target=self.project) timeline = Timeline(self.user) timeline.save(action) self.assertEqual(timeline.get_private_count(), 2) self.assertEqual(timeline.get_public_count(), 2) self.assertEqual(timeline.get_private_count(target=Project), 1) self.assertEqual(timeline.get_public_count(target=Project), 1) timeline = Timeline(self.newbie) self.assertEqual(timeline.get_private_count(), 0) self.assertEqual(timeline.get_unread_count(), 0) timeline.mark_as_read(timestamp=datetime.now() + timedelta(days=1)) self.assertEqual(timeline.get_unread_count(), 0) self.assertEqual(timeline.get_public_count(), 0)
def test_signals_actions(self): from ..models import follow, unfollow from .sequere_registry import JoinAction from sequere.contrib.timeline import Timeline timeline = Timeline(self.user) action = JoinAction(self.user) timeline.save(action) follow(self.newbie, self.user) timeline = Timeline(self.newbie) self.assertEqual(timeline.get_private_count(), 1) self.assertEqual(timeline.get_unread_count(), 1) unfollow(self.newbie, self.user) self.assertEqual(timeline.get_private_count(), 0) self.assertEqual(timeline.get_unread_count(), 0)
def test_signals_actions(self): from ..models import follow, unfollow from .sequere_registry import JoinAction from sequere.contrib.timeline import Timeline timeline = Timeline(self.user) action = JoinAction(self.user) timeline.save(action) follow(self.newbie, self.user) timeline = Timeline(self.newbie) self.assertEqual(timeline.get_private_count(), 1) self.assertEqual(timeline.get_unread_count(), 1) unfollow(self.newbie, self.user) self.assertEqual(timeline.get_private_count(), 0) self.assertEqual(timeline.get_unread_count(), 0)