本文整理汇总了Python中avocado.models.DataQuery.count方法的典型用法代码示例。如果您正苦于以下问题:Python DataQuery.count方法的具体用法?Python DataQuery.count怎么用?Python DataQuery.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类avocado.models.DataQuery
的用法示例。
在下文中一共展示了DataQuery.count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_count
# 需要导入模块: from avocado.models import DataQuery [as 别名]
# 或者: from avocado.models.DataQuery import count [as 别名]
def test_count(self):
c = DataConcept.objects.get(fields__model_name='title',
fields__field_name='salary')
json = {
'context': {
'field': 'tests.title.salary',
'operator': 'gt',
'value': '1000'
},
'view': [{
'concept': c.id,
'visible': True,
}]
}
query = DataQuery(json)
# Default tree is Employee so we should get 6 unique employee objects
# regardless of distinct setting since all are distinct.
self.assertEqual(query.count(), 6)
self.assertEqual(query.count(distinct=False), 6)
# Switching the tree should allow us to exercise the distinct keyword
# since there are 3 titles all with the same 15,000 unit salary. We
# need to eliminate the PK so that we are only getting salaries
# back. Including the PK causes everything to be unique.
self.assertEqual(query.count(tree='title', include_pk=False), 5)
self.assertEqual(
query.count(tree='title', include_pk=False, distinct=False), 7)