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


Python TestDisk.one方法代码示例

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


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

示例1: test_invalidonetoone

# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import one [as 别名]
 def test_invalidonetoone(self):
     """
     Validates that if a one-to-one is used as a one-to-many an exception will be raised
     """
     machine = TestMachine()
     machine.name = 'machine'
     machine.save()
     self.assertIsNone(machine.one, 'There should not be any disk(s)')
     disk1 = TestDisk()
     disk1.name = 'disk1'
     disk1.one = machine
     disk1.save()
     self.assertEqual(machine.one, disk1, 'The correct disk should be returned')
     disk2 = TestDisk()
     disk2.name = 'disk2'
     disk2.one = machine
     disk2.save()
     with self.assertRaises(InvalidRelationException):
         _ = machine.one
开发者ID:BillTheBest,项目名称:openvstorage,代码行数:21,代码来源:test_basic.py

示例2: test_1_to_1

# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import one [as 别名]
    def test_1_to_1(self):
        """
        Validates whether 1-to-1 relations work correct
        """
        machine = TestMachine()
        machine.name = 'machine'
        machine.save()

        self.assertIsNone(machine.one, 'The machine should not have a reverse disk relation')
        self.assertIsNone(machine.one_guid, 'The machine should have an empty disk _guid property')

        disk = TestDisk()
        disk.name = 'test'
        disk.one = machine
        disk.save()

        self.assertIsNotNone(machine.one, 'The machine should have a reverse disk relation')
        self.assertEqual(machine.one.name, 'test', 'The reverse 1-to-1 relation should work')
        self.assertEqual(disk.one.name, 'machine', 'The normal 1-to-1 relation should work')
        self.assertEqual(machine.one_guid, disk.guid, 'The reverse disk should be the correct one')

        with self.assertRaises(RuntimeError):
            machine.one = disk
开发者ID:BillTheBest,项目名称:openvstorage,代码行数:25,代码来源:test_basic.py


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