Beispiel #1
0
    def testRaisesOnDeletingMultipleNotifications(self):
        # Check that there are three pending notifications and no shown ones yet.
        (pending, shown) = self._GetNotifications()
        self.assertLen(pending, 3)
        self.assertEmpty(shown)

        # Delete all pending notifications on TIME_0.
        args = user_plugin.ApiDeletePendingUserNotificationArgs(
            timestamp=self.TIME_0)
        with self.assertRaises(aff4_users.UniqueKeyError):
            self.handler.Handle(args, token=self.token)

        # Check that the notifications were not changed in the process.
        (pending, shown) = self._GetNotifications()
        self.assertLen(pending, 3)
        self.assertEmpty(shown)
Beispiel #2
0
    def testUnknownTimestampIsIgnored(self):
        # Check that there are three pending notifications and no shown ones yet.
        (pending, shown) = self._GetNotifications()
        self.assertLen(pending, 3)
        self.assertEmpty(shown)

        # A timestamp not matching any pending notifications does not change any of
        # the collections.
        args = user_plugin.ApiDeletePendingUserNotificationArgs(
            timestamp=self.TIME_2)
        self.handler.Handle(args, token=self.token)

        # We should still have the same number of pending and shown notifications.
        (pending, shown) = self._GetNotifications()
        self.assertLen(pending, 3)
        self.assertEmpty(shown)
Beispiel #3
0
  def testDeletesFromPendingAndAddsToShown(self):
    # Check that there are three pending notifications and no shown ones yet.
    (pending, shown) = self._GetNotifications()
    self.assertLen(pending, 3)
    self.assertEmpty(shown)

    # Delete a pending notification.
    args = user_plugin.ApiDeletePendingUserNotificationArgs(
        timestamp=self.TIME_1)
    self.handler.Handle(args, context=self.context)

    # After the deletion, two notifications should be pending and one shown.
    (pending, shown) = self._GetNotifications()
    self.assertLen(pending, 2)
    self.assertLen(shown, 1)
    self.assertIn("<some other message>", shown[0].message)
    self.assertEqual(shown[0].timestamp, self.TIME_1)