Example #1
0
 def test_for_user(self):
     """Notifications should be filterable by a single user."""
     user_notification = factories.NotificationFactory(user=self.user)
     user_notifications = Notification.objects.for_user(self.user)
     ok_(user_notification in user_notifications,
         'A notification for the user should be in the set returned.')
     ok_(self.notification not in user_notifications,
         'A notification for another user should not be in the set returned.')
Example #2
0
 def test_for_object(self):
     """Notifications should be filterable by a single object."""
     foia = factories.FOIARequestFactory()
     _action = new_action(factories.UserFactory(), 'submitted', target=foia)
     object_notification = factories.NotificationFactory(user=self.user, action=_action)
     object_notifications = Notification.objects.for_object(foia)
     ok_(object_notification in object_notifications,
         'A notification for the object should be in the set returned.')
     ok_(self.notification not in object_notifications,
         'A notification not including the object should not be in the set returned.')
Example #3
0
 def setUp(self):
     self.user = factories.UserFactory()
     self.action = new_action(self.user, 'acted')
     self.notification = factories.NotificationFactory()
Example #4
0
 def test_when_unread(self, mock_send):
     """The send method should be called when a user has unread notifications."""
     factories.NotificationFactory(user=self.user)
     tasks.daily_digest()
     mock_send.assert_called_with(self.user, u'Daily Digest',
                                  relativedelta(days=1))