Exemple #1
0
def notification_delete(context, notification_uuid):

    count = model_query(context, models.Notification).filter_by(
        notification_uuid=notification_uuid).soft_delete(
            synchronize_session=False)

    if count == 0:
        raise exception.NotificationNotFound(id=notification_uuid)
Exemple #2
0
def notification_get_by_id(context, notification_id):
    query = model_query(context,
                        models.Notification).filter_by(id=notification_id)

    result = query.first()
    if not result:
        raise exception.NotificationNotFound(id=notification_id)

    return result
Exemple #3
0
    def get_notification(self, context, notification_uuid):
        """Get a single notification with the given notification_uuid."""
        if uuidutils.is_uuid_like(notification_uuid):
            LOG.debug("Fetching notification by uuid %s", notification_uuid)
            notification = objects.Notification.get_by_uuid(
                context, notification_uuid)
        else:
            LOG.debug("Failed to fetch notification by "
                      "uuid %s", notification_uuid)
            raise exception.NotificationNotFound(id=notification_uuid)

        return notification
Exemple #4
0
    def test_show_with_non_existing_uuid(self, mock_get_notification):

        mock_get_notification.side_effect = exception.NotificationNotFound(
            id="2")
        self.assertRaises(exc.HTTPNotFound, self.controller.show, self.req,
                          "2")