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_simple_timeline(self): from .sequere_registry import JoinAction, User from sequere.contrib.timeline import Timeline timeline = Timeline(self.user) timeline.save(JoinAction(self.user)) self.assertEqual(timeline.get_private_count(), 1) self.assertEqual(timeline.get_public_count(), 1) self.assertEqual(timeline.get_public_count(action='join'), 1) self.assertEqual(timeline.get_private_count(action='join'), 1) self.assertEqual(timeline.get_private_count(action=JoinAction), 1) self.assertEqual(timeline.get_public_count(action=JoinAction), 1) self.assertEqual(timeline.get_private_count(target=self.user), 1) self.assertEqual(timeline.get_private_count(target=User), 1) self.assertEqual(timeline.get_public_count(target=self.user), 1) self.assertEqual(timeline.get_public_count(target=User), 1) qs = timeline.get_private() self.assertEqual(qs.count(), 1) results = qs.all() self.assertEqual(len(results), 1) qs = timeline.get_public() self.assertEqual(qs.count(), 1) results = qs.all() self.assertEqual(len(results), 1)
def test_simple_timeline(self): from .sequere_registry import JoinAction, User from sequere.contrib.timeline import Timeline timeline = Timeline(self.user) timeline.save(JoinAction(self.user)) self.assertEqual(timeline.get_private_count(), 1) self.assertEqual(timeline.get_public_count(), 1) self.assertEqual(timeline.get_public_count(action='join'), 1) self.assertEqual(timeline.get_private_count(action='join'), 1) self.assertEqual(timeline.get_private_count(action=JoinAction), 1) self.assertEqual(timeline.get_public_count(action=JoinAction), 1) self.assertEqual(timeline.get_private_count(target=self.user), 1) self.assertEqual(timeline.get_private_count(target=User), 1) self.assertEqual(timeline.get_public_count(target=self.user), 1) self.assertEqual(timeline.get_public_count(target=User), 1) qs = timeline.get_private() self.assertEqual(qs.count(), 1) results = qs.all() self.assertEqual(len(results), 1) qs = timeline.get_public() self.assertEqual(qs.count(), 1) results = qs.all() self.assertEqual(len(results), 1)