def testRaisesOnDeletingNonExistingNotification(self): # Check that there are two pending notifications and no shown ones yet. (pending, shown) = self._GetGlobalNotifications() self.assertEqual(len(pending), 2) self.assertEqual(len(shown), 0) # Delete a non-existing pending notification. args = user_plugin.ApiDeletePendingGlobalNotificationArgs( type=aff4_users.GlobalNotification.Type.WARNING) with self.assertRaises(user_plugin.GlobalNotificationNotFoundError): self.handler.Handle(args, token=self.token) # Check that the notifications were not changed in the process. (pending, shown) = self._GetGlobalNotifications() self.assertEqual(len(pending), 2) self.assertEqual(len(shown), 0)
def testDeletesFromPendingAndAddsToShown(self): # Check that there are two pending notifications and no shown ones yet. (pending, shown) = self._GetGlobalNotifications() self.assertEqual(len(pending), 2) self.assertEqual(len(shown), 0) # Delete one of the pending notifications. args = user_plugin.ApiDeletePendingGlobalNotificationArgs( type=aff4_users.GlobalNotification.Type.INFO) self.handler.Handle(args, token=self.token) # After the deletion, one notification should be pending and one shown. (pending, shown) = self._GetGlobalNotifications() self.assertEqual(len(pending), 1) self.assertEqual(len(shown), 1) self.assertEqual(pending[0].header, "Oh no, we're doomed!") self.assertEqual(shown[0].header, "Nothing to worry about!")