Exemplo n.º 1
0
    def test_user_should_have_no_notifications_after_clear(self):
        self.assert_queryset_equal(get_user_notifications(self.user_with_notifications),
                                   self.all_notifications)

        clear_user_notifications(self.user_with_notifications)

        self.assert_queryset_equal(get_user_notifications(self.user_with_notifications),
                                   [])
Exemplo n.º 2
0
 def test_should_return_unread_first_then_read_notifications_when_user_got_notifications(
         self):
     returned_notifications = get_user_notifications(
         self.user_with_notifications)
     self.assert_queryset_equal(returned_notifications,
                                self.all_notifications)
     self.assertCountEqual(returned_notifications[:5],
                           self.unread_notifications)
Exemplo n.º 3
0
 def test_should_return_empty_list_when_user_has_no_notifications(self):
     self.assert_queryset_equal(
         get_user_notifications(self.user_without_notifications), [])
Exemplo n.º 4
0
def get_notifications(context):
    user = context["request"].user

    return get_user_notifications(user)