def test_get_and_mark_unread(self): user = get_user_model().objects.get(pk=2) target = get_user_model().objects.get(pk=1) notification = Notification(owner=user, actor=user, verb="tagged", obj="Wonderful", target=target, title="John tagged you with \"Wonderful\"", viewed=False) notification.save() with self.assertNumQueries(2): Notification.get_and_mark_unread(target) notification = Notification.objects.get(pk=notification.pk) self.assertTrue(notification.viewed)