當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。