コード例 #1
0
    def test_action_delete_not_found(self, mock_find):
        mock_find.side_effect = exc.ActionNotFound(action='Bogus')

        ex = self.assertRaises(rpc.ExpectedException, self.eng.action_delete,
                               self.ctx, 'Bogus')

        self.assertEqual(exc.ActionNotFound, ex.exc_info[0])
コード例 #2
0
    def test_action_get_not_found(self, mock_find):
        mock_find.side_effect = exc.ActionNotFound(action='Bogus')

        ex = self.assertRaises(rpc.ExpectedException, self.eng.action_get,
                               self.ctx, 'Bogus')
        self.assertEqual(exc.ActionNotFound, ex.exc_info[0])
        mock_find.assert_called_once_with(self.ctx, 'Bogus')
コード例 #3
0
def action_update(context, action_id, values):
    with session_for_write() as session:
        action = session.query(models.Action).get(action_id)
        if not action:
            raise exception.ActionNotFound(action=action_id)

        action.update(values)
        action.save(session)
コード例 #4
0
def action_lock_check(context, action_id, owner=None):
    action = model_query(context, models.Action).get(action_id)
    if not action:
        raise exception.ActionNotFound(action=action_id)

    if owner:
        return owner if owner == action.owner else action.owner
    else:
        return action.owner if action.owner else None
コード例 #5
0
ファイル: base.py プロジェクト: KongJustin/senlin
    def load(cls, context, action_id=None, db_action=None, show_deleted=False):
        '''Retrieve an action from database.'''
        if db_action is None:
            db_action = db_api.action_get(context, action_id,
                                          show_deleted=show_deleted)

            if db_action is None:
                raise exception.ActionNotFound(action=action_id)

        return cls._from_db_record(db_action)
コード例 #6
0
ファイル: base.py プロジェクト: GingoBang/senlin
    def load(cls, context, action_id=None, db_action=None):
        """Retrieve an action from database.

        :param context: Instance of request context.
        :param action_id: An UUID for the action to deserialize.
        :param db_action: An action object for the action to deserialize.
        :return: A `Action` object instance.
        """
        if db_action is None:
            db_action = db_api.action_get(context, action_id)
            if db_action is None:
                raise exception.ActionNotFound(action=action_id)

        return cls._from_db_record(db_action)
コード例 #7
0
    def test_action_get_not_found(self, mock_enforce):
        self._mock_enforce_setup(mock_enforce, 'get', True)
        action_id = 'non-existent-action'
        req = self._get('/actions/%(action_id)s' % {'action_id': action_id})

        error = senlin_exc.ActionNotFound(action=action_id)
        mock_call = self.patchobject(rpc_client.EngineClient, 'call')
        mock_call.side_effect = shared.to_remote_error(error)

        resp = shared.request_with_middleware(fault.FaultWrapper,
                                              self.controller.get,
                                              req, action_id=action_id)

        self.assertEqual(404, resp.json['code'])
        self.assertEqual('ActionNotFound', resp.json['error']['type'])