示例#1
0
    def test_update_capsule(self, mock_update, mock_write, mock_read):
        mock_read.side_effect = etcd.EtcdKeyNotFound
        capsule = utils.create_test_capsule(context=self.context)
        new_meta_name = 'new_meta_name'

        mock_read.side_effect = lambda *args: FakeEtcdResult(capsule.as_dict())
        dbapi.update_capsule(self.context, capsule.uuid,
                             {'meta_name': new_meta_name})
        self.assertEqual(
            new_meta_name,
            json.loads(mock_update.call_args_list[0][0][0].value.decode(
                'utf-8'))['meta_name'])
示例#2
0
文件: capsule.py 项目: ppatel826/zun
    def save(self, context=None):
        """Save updates to this Capsule.

        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.: Capsule(context)
        """
        updates = self.obj_get_changes()
        dbapi.update_capsule(context, self.uuid, updates)

        self.obj_reset_changes()
示例#3
0
    def test_update_capsule(self):
        capsule = utils.create_test_capsule(context=self.context)
        current_meta_name = capsule.meta_name
        new_meta_name = 'new-meta-name'
        self.assertNotEqual(current_meta_name, new_meta_name)

        res = dbapi.update_capsule(self.context, capsule.id,
                                   {'meta_name': new_meta_name})
        self.assertEqual(new_meta_name, res.meta_name)