本文整理汇总了Python中ovs.dal.hybrids.t_testdisk.TestDisk.copy方法的典型用法代码示例。如果您正苦于以下问题:Python TestDisk.copy方法的具体用法?Python TestDisk.copy怎么用?Python TestDisk.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ovs.dal.hybrids.t_testdisk.TestDisk
的用法示例。
在下文中一共展示了TestDisk.copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_copy
# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import copy [as 别名]
def test_copy(self):
"""
Validates whether the copy function works correct
"""
machine = TestMachine()
machine.name = 'testmachine1'
machine.save()
disk1 = TestDisk()
disk1.name = 'test1'
disk1.size = 100
disk1.order = 1
disk1.type = 'ONE'
disk1.machine = machine
disk1.save()
disk2 = TestDisk()
disk2.copy(disk1)
self.assertEqual(disk2.name, 'test1', 'Properties should be copied')
self.assertEqual(disk2.size, 100, 'Properties should be copied')
self.assertEqual(disk2.order, 1, 'Properties should be copied')
self.assertEqual(disk2.type, 'ONE', 'Properties should be copied')
self.assertEqual(disk2.machine, None, 'Relations should not be copied')
disk3 = TestDisk()
disk3.copy(disk1, include_relations=True)
self.assertEqual(disk3.machine.name, 'testmachine1', 'Relations should be copied')
disk4 = TestDisk()
disk4.copy(disk1, include=['name'])
self.assertEqual(disk4.name, 'test1', 'Name should be copied')
self.assertEqual(disk4.size, 0, 'Size should not be copied')
self.assertEqual(disk4.machine, None, 'Relations should not be copied')
disk5 = TestDisk()
disk5.copy(disk1, exclude=['name'])
self.assertEqual(disk5.name, None, 'Name should not be copied')
self.assertEqual(disk5.size, 100, 'Size should be copied')
self.assertEqual(disk5.machine, None, 'Relations should not be copied')