当前位置: 首页>>代码示例>>Python>>正文


Python fields.UUIDField方法代码示例

本文整理汇总了Python中oslo_versionedobjects.fields.UUIDField方法的典型用法代码示例。如果您正苦于以下问题:Python fields.UUIDField方法的具体用法?Python fields.UUIDField怎么用?Python fields.UUIDField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oslo_versionedobjects.fields的用法示例。


在下文中一共展示了fields.UUIDField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_refresh

# 需要导入模块: from oslo_versionedobjects import fields [as 别名]
# 或者: from oslo_versionedobjects.fields import UUIDField [as 别名]
def test_refresh(self):
        @objects.base.KarborObjectRegistry.register_if(False)
        class MyTestObject(objects.base.KarborObject,
                           objects.base.KarborObjectDictCompat,
                           objects.base.KarborComparableObject):
            fields = {'id': fields.UUIDField(),
                      'name': fields.StringField()}

        test_obj = MyTestObject(id='1', name='foo')
        refresh_obj = MyTestObject(id='1', name='bar')
        with mock.patch(
                'karbor.objects.base.KarborObject.get_by_id') as get_by_id:
            get_by_id.return_value = refresh_obj

            test_obj.refresh()
            self._compare(self, refresh_obj, test_obj) 
开发者ID:openstack,项目名称:karbor,代码行数:18,代码来源:test_base.py

示例2: setUp

# 需要导入模块: from oslo_versionedobjects import fields [as 别名]
# 或者: from oslo_versionedobjects.fields import UUIDField [as 别名]
def setUp(self):
        super(TestUUID, self).setUp()
        self.field = fields.UUIDField()
        self.coerce_good_values = [
            ('da66a411-af0e-4829-9b67-475017ddd152',
                'da66a411-af0e-4829-9b67-475017ddd152'),
            ('da66a411af0e48299b67475017ddd152',
                'da66a411af0e48299b67475017ddd152'),
            ('DA66A411-AF0E-4829-9B67-475017DDD152',
                'DA66A411-AF0E-4829-9B67-475017DDD152'),
            ('DA66A411AF0E48299b67475017DDD152',
                'DA66A411AF0E48299b67475017DDD152'),
            # These values are included to ensure there is not change in
            # behaviour - only when we can remove the old UUID behaviour can
            #  we add these to the "self.coerce_bad_values" list
            ('da66a411-af0e-4829-9b67',
                'da66a411-af0e-4829-9b67'),
            ('da66a411-af0e-4829-9b67-475017ddd152548999',
                'da66a411-af0e-4829-9b67-475017ddd152548999'),
            ('da66a411-af0e-4829-9b67-475017ddz152',
                'da66a411-af0e-4829-9b67-475017ddz152'),
            ('fake_uuid', 'fake_uuid'),
            (u'fake_uāid', u'fake_uāid'),
            (b'fake_u\xe1id'.decode('latin_1'),
                b'fake_u\xe1id'.decode('latin_1')),
            ('1', '1'),
            (1, '1')
        ]
        self.to_primitive_values = self.coerce_good_values[0:1]
        self.from_primitive_values = self.coerce_good_values[0:1] 
开发者ID:openstack,项目名称:oslo.versionedobjects,代码行数:32,代码来源:test_fields.py

示例3: test_get_schema

# 需要导入模块: from oslo_versionedobjects import fields [as 别名]
# 或者: from oslo_versionedobjects.fields import UUIDField [as 别名]
def test_get_schema(self):
        field = fields.UUIDField()
        schema = field.get_schema()
        self.assertEqual(['string'], schema['type'])
        self.assertEqual(False, schema['readonly'])
        pattern = schema['pattern']
        for _, valid_val in self.coerce_good_values[:4]:
            self.assertRegex(valid_val, pattern)
        invalid_vals = [x for x in self.coerce_bad_values if type(x) == 'str']
        for invalid_val in invalid_vals:
            self.assertNotRegex(invalid_val, pattern) 
开发者ID:openstack,项目名称:oslo.versionedobjects,代码行数:13,代码来源:test_fields.py

示例4: test_refresh_no_id_field

# 需要导入模块: from oslo_versionedobjects import fields [as 别名]
# 或者: from oslo_versionedobjects.fields import UUIDField [as 别名]
def test_refresh_no_id_field(self):
        @objects.base.KarborObjectRegistry.register_if(False)
        class MyTestObjectNoId(objects.base.KarborObject,
                               objects.base.KarborObjectDictCompat,
                               objects.base.KarborComparableObject):
            fields = {'uuid': fields.UUIDField()}

        test_obj = MyTestObjectNoId(uuid='1', name='foo')
        self.assertRaises(NotImplementedError, test_obj.refresh) 
开发者ID:openstack,项目名称:karbor,代码行数:11,代码来源:test_base.py


注:本文中的oslo_versionedobjects.fields.UUIDField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。