本文整理汇总了Python中ovs.dal.hybrids.t_testdisk.TestDisk.serialize方法的典型用法代码示例。如果您正苦于以下问题:Python TestDisk.serialize方法的具体用法?Python TestDisk.serialize怎么用?Python TestDisk.serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ovs.dal.hybrids.t_testdisk.TestDisk
的用法示例。
在下文中一共展示了TestDisk.serialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_serialization
# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import serialize [as 别名]
def test_serialization(self):
"""
Validates whether serialization works as expected
"""
machine = TestMachine()
machine.name = 'machine'
machine.save()
disk = TestDisk()
disk.name = 'disk'
disk.machine = machine
disk.save()
dictionary = disk.serialize()
self.assertIn('name', dictionary, 'Serialized object should have correct properties')
self.assertEqual(dictionary['name'], 'disk', 'Serialized object should have correct name')
self.assertIn('machine_guid', dictionary, 'Serialized object should have correct depth')
self.assertEqual(dictionary['machine_guid'], machine.guid,
'Serialized object should have correct properties')
dictionary = disk.serialize(depth=1)
self.assertIn('machine', dictionary, 'Serialized object should have correct depth')
self.assertEqual(dictionary['machine']['name'], 'machine',
'Serialized object should have correct properties at all depths')