本文整理汇总了Python中ovs.dal.hybrids.t_testdisk.TestDisk.parent方法的典型用法代码示例。如果您正苦于以下问题:Python TestDisk.parent方法的具体用法?Python TestDisk.parent怎么用?Python TestDisk.parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ovs.dal.hybrids.t_testdisk.TestDisk
的用法示例。
在下文中一共展示了TestDisk.parent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ownrelations
# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import parent [as 别名]
def test_ownrelations(self):
"""
Validates whether relations to the object itself are working
"""
pdisk = TestDisk()
pdisk.name = 'parent'
pdisk.save()
cdisk1 = TestDisk()
cdisk1.name = 'child 1'
cdisk1.size = 100
cdisk1.parent = pdisk
cdisk1.save()
cdisk2 = TestDisk()
cdisk2.name = 'child 2'
cdisk2.size = 100
cdisk2.parent = pdisk
cdisk2.save()
self.assertEqual(len(pdisk.children), 2, 'There should be 2 children ({0})'.format(len(pdisk.children)))
self.assertEqual(cdisk1.parent.name, 'parent', 'Parent should be loaded correctly')
data = DataList({'object': TestDisk,
'data': DataList.select.GUIDS,
'query': {'type': DataList.where_operator.AND,
'items': [('parent.name', DataList.operator.EQUALS, 'parent')]}}).data
datalist = DataObjectList(data, TestDisk)
self.assertEqual(len(datalist), 2, 'There should be two items ({0})'.format(len(datalist)))
cdisk2.parent = None
cdisk2.save()
data = DataList({'object': TestDisk,
'data': DataList.select.GUIDS,
'query': {'type': DataList.where_operator.AND,
'items': [('parent.name', DataList.operator.EQUALS, 'parent')]}}).data
datalist = DataObjectList(data, TestDisk)
self.assertEqual(len(datalist), 1, 'There should be one item ({0})'.format(len(datalist)))