def test_add_notification(self):
     data = {'data': 'some data here'}
     for i, uid in enumerate(self.uids[:10], start=1):
         Notification(uid, self.receivers, data).send()
         assert len(Notification.get_data(self.test_user1)) == i
         assert Notification.unread_count(self.test_user1) == i
         assert len(Notification.get_data(self.test_user2)) == i
         assert Notification.unread_count(self.test_user2) == i
    def test_mark_as_read(self):
        data = {'data': 'some data here'}
        for uid in self.uids:
            Notification(uid, self.receivers, data).send()

        to_mark_as_read = self.uids[:5] + self.uids[20:30] + self.uids[40:50]

        for i, uid in enumerate(to_mark_as_read, start=1):
            Notification.mark_as_read(self.test_user1, uid)
            assert Notification.unread_count(self.test_user1) == 50-i

        assert Notification.unread_count(self.test_user2) == 50
        Notification.mark_all_as_read(self.test_user2)
        assert Notification.unread_count(self.test_user2) == 0
Exemple #3
0
 def unread_notification_count(self):
     from vilya.models.notification import Notification
     return Notification.unread_count(self.name)
Exemple #4
0
 def unread_notification_count(self):
     from vilya.models.notification import Notification
     return Notification.unread_count(self.name)