コード例 #1
0
 def test_update_resource_class(self, mock_update, mock_write, mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     resource_class = utils.create_test_resource_class(context=self.context)
     old_name = resource_class.name
     new_name = 'new-name'
     self.assertNotEqual(old_name, new_name)
     mock_read.side_effect = lambda *args: FakeEtcdResult(resource_class.
                                                          as_dict())
     dbapi.update_resource_class(self.context, resource_class.uuid,
                                 {'name': new_name})
     self.assertEqual(
         new_name,
         json.loads(mock_update.call_args_list[0][0][0].value)['name'])
コード例 #2
0
ファイル: resource_class.py プロジェクト: zwphit/zun
    def save(self, context=None):
        """Save updates to this ResourceClass.

        Updates will be made column by column based on the result
        of self.what_changed().

        :param context: Security context. NOTE: This should only
                        be used internally by the indirection_api.
                        Unfortunately, RPC requires context as the first
                        argument, even though we don't use it.
                        A context should be set when instantiating the
                        object, e.g.: ResourceClass(context)
        """
        updates = self.obj_get_changes()
        dbapi.update_resource_class(context, self.uuid, updates)

        self.obj_reset_changes()
コード例 #3
0
ファイル: test_resource_class.py プロジェクト: wanghuiict/zun
    def test_update_resource_class(self):
        resource = utils.create_test_resource_class(context=self.context)
        old_name = resource.name
        new_name = 'new-name'
        self.assertNotEqual(old_name, new_name)

        res = dbapi.update_resource_class(self.context, resource.id,
                                          {'name': new_name})
        self.assertEqual(new_name, res.name)
コード例 #4
0
    def test_update_resource_class(self):
        resource = utils.create_test_resource_class(context=self.context)
        old_name = resource.name
        new_name = 'new-name'
        self.assertNotEqual(old_name, new_name)

        res = dbapi.update_resource_class(
            self.context, resource.id, {'name': new_name})
        self.assertEqual(new_name, res.name)