예제 #1
0
 def notify_user(self):
     notify_user(self.user,
                 "Test notify %(token)s",
                 "/users/",
                 "test",
                 {'token': 'Bob'},
                 self.user)
     self.user = get_user_model().objects.get(id=self.user.id)
예제 #2
0
    def test_read_all_user_alerts(self):
        """read_all_user_alerts marks user notifications as read"""
        api.notify_user(self.test_user, "Test notify %(token)s", "/users/",
                        "test", {'token': 'Bob'}, self.test_user)
        self.reload_test_user()

        api.read_all_user_alerts(self.test_user)
        self.assertEqual(self.test_user.new_notifications, 0)

        queryset = self.test_user.misago_notifications.filter(is_new=True)
        self.assertEqual(queryset.count(), 0)
예제 #3
0
파일: test_api.py 프로젝트: dahito/Misago
    def test_notify_user(self):
        """notify_user sets new notification on user"""
        api.notify_user(self.test_user,
                        "Test notify %(token)s",
                        "/users/",
                        "test",
                        {'token': 'Bob'},
                        self.test_user)

        self.reload_test_user()
        self.assertEqual(self.test_user.new_notifications, 1)
예제 #4
0
    def test_read_all_user_alerts(self):
        """read_all_user_alerts marks user notifications as read"""
        api.notify_user(self.test_user,
                        "Test notify %(token)s",
                        "/users/",
                        "test",
                        {'token': 'Bob'},
                        self.test_user)
        self.reload_test_user()

        api.read_all_user_alerts(self.test_user)
        self.assertEqual(self.test_user.new_notifications, 0)

        queryset = self.test_user.misago_notifications.filter(is_new=True)
        self.assertEqual(queryset.count(), 0)
예제 #5
0
파일: test_api.py 프로젝트: dahito/Misago
    def test_read_user_notification(self):
        """read_user_notification reads user notification"""
        api.notify_user(self.test_user,
                        "Test notify %(token)s",
                        "/users/",
                        "test",
                        {'token': 'Bob'},
                        self.test_user)
        self.reload_test_user()

        api.read_user_notification(self.test_user, "test")

        self.assertEqual(self.test_user.new_notifications, 0)
        notifications_qs = self.test_user.notifications.filter(is_new=True)
        self.assertEqual(notifications_qs.count(), 0)
예제 #6
0
 def notify_user(self):
     notification = notify_user(self.user,
                                "Test notify %(token)s",
                                "/users/",
                                "test",
                                {'token': 'Bob'},
                                self.user)
     self.user = get_user_model().objects.get(id=self.user.id)
     return notification
예제 #7
0
    def test_notify_user(self):
        """notify_user sets new notification on user"""
        notification = api.notify_user(self.test_user, "Test notify %(token)s",
                                       "/users/", "test", {'token': 'Bob'},
                                       self.test_user)
        self.assertTrue(notification.is_valid)

        self.reload_test_user()
        self.assertEqual(self.test_user.new_notifications, 1)
예제 #8
0
    def test_assert_real_new_notifications_count(self):
        """assert_real_new_notifications_count syncs user notifications"""
        api.notify_user(self.test_user, "Test notify %(token)s", "/users/",
                        "test", {'token': 'Bob'}, self.test_user)
        self.reload_test_user()
        api.read_all_user_alerts(self.test_user)

        self.test_user.new_notifications = 42
        self.test_user.save()

        self.reload_test_user()
        self.assertEqual(self.test_user.new_notifications, 42)

        queryset = self.test_user.misago_notifications.filter(is_new=True)
        self.assertEqual(queryset.count(), 0)

        api.assert_real_new_notifications_count(self.test_user)
        self.reload_test_user()
        self.assertEqual(self.test_user.new_notifications, 0)
예제 #9
0
    def test_assert_real_new_notifications_count(self):
        """assert_real_new_notifications_count syncs user notifications"""
        api.notify_user(self.test_user,
                        "Test notify %(token)s",
                        "/users/",
                        "test",
                        {'token': 'Bob'},
                        self.test_user)
        self.reload_test_user()
        api.read_all_user_alerts(self.test_user)

        self.test_user.new_notifications = 42
        self.test_user.save()

        self.reload_test_user()
        self.assertEqual(self.test_user.new_notifications, 42)

        queryset = self.test_user.misago_notifications.filter(is_new=True)
        self.assertEqual(queryset.count(), 0)

        api.assert_real_new_notifications_count(self.test_user)
        self.reload_test_user()
        self.assertEqual(self.test_user.new_notifications, 0)