本文整理汇总了Python中tcms.core.db.GroupByResult类的典型用法代码示例。如果您正苦于以下问题:Python GroupByResult类的具体用法?Python GroupByResult怎么用?Python GroupByResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GroupByResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: status_matrix
def status_matrix(self, form):
sql, params = self._prepare_sql(
form, sqls.by_plan_build_detail_status_matrix)
rows = SQLExecution(sql, params, with_field_name=False).rows
status_matrix = GroupByResult()
plan_ids = build_ids = run_ids = []
for plan_id, build_id, run_id, status_name, _ in rows:
plan_ids.append(plan_id)
build_ids.append(build_id)
run_ids.append(run_id)
plans = {
plan.pk: plan for plan in TestPlan.objects.filter(
pk__in=plan_ids).only('pk', 'name')
}
test_builds = {
build.pk: build for build in TestBuild.objects.filter(
pk__in=build_ids).only('pk', 'name')
}
runs = {
run.pk: run for run in TestRun.objects.filter(
pk__in=run_ids).only('pk', 'summary')
}
for row in rows:
plan_id, build_id, run_id, status_name, total_count = row
builds = status_matrix.setdefault(plans[plan_id], GroupByResult())
runs = builds.setdefault(test_builds[build_id], GroupByResult())
status_subtotal = runs.setdefault(runs[run_id], GroupByResult())
status_subtotal[status_name] = total_count
return status_matrix
开发者ID:tkdchen,项目名称:Nitrate,代码行数:33,代码来源:data.py
示例2: status_matrix_groupby_builds
def status_matrix_groupby_builds(self, form):
builds = GroupByResult({})
query = self._filter_query(
form,
TestCaseRun.objects.values(
'build',
'tested_by',
'case_run_status__name'
).annotate(
total_count=Count('pk')
)
)
for row in query:
build_id = row['build']
tested_by_id = row['tested_by']
name = row['case_run_status__name']
total_count = row['total_count']
tested_by_ids = builds.setdefault(build_id, GroupByResult({}))
status_subtotal = tested_by_ids.setdefault(tested_by_id,
GroupByResult({}))
status_subtotal[name] = total_count
return builds
开发者ID:MrSenko,项目名称:Nitrate,代码行数:25,代码来源:data.py
示例3: status_matrix
def status_matrix(self, form):
status_matrix = GroupByResult()
query = self._filter_query(
form,
TestCaseRun.objects.values(
'run__plan',
'run__plan__name',
'case_run_status__name'
).filter(
case_run_status__name__in=('PASSED', 'FAILED')
).annotate(
total_count=Count('run', distinct=True)
)
)
for row in query:
plan_id = row['run__plan']
plan_name = row['run__plan__name']
status_name = row['case_run_status__name']
total_count = row['total_count']
plan = TestPlan(pk=plan_id, name=plan_name)
status_subtotal = status_matrix.setdefault(plan, GroupByResult())
status_subtotal[status_name] = total_count
return status_matrix
开发者ID:MrSenko,项目名称:Nitrate,代码行数:25,代码来源:data.py
示例4: status_matrix
def status_matrix(self, form):
sql, params = self._prepare_sql(form,
sqls.by_plan_build_status_matrix)
rows = SQLExecution(sql, params, with_field_name=False).rows
status_matrix = GroupByResult()
for plan_id, plan_name, status_name, total_count in rows:
plan = TestPlan(pk=plan_id, name=plan_name)
status_subtotal = status_matrix.setdefault(plan, GroupByResult())
status_subtotal[status_name] = total_count
return status_matrix
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:10,代码来源:data.py
示例5: passed_failed_case_runs_subtotal
def passed_failed_case_runs_subtotal(self, form):
sql, params = self._prepare_sql(
form, sqls.by_plan_tags_passed_failed_case_runs_subtotal)
sql_executor = SQLExecution(sql, params, with_field_name=False)
rows = sql_executor.rows
tags = GroupByResult()
for tag_id, name, total_count in rows:
status_subtotal = tags.setdefault(tag_id, GroupByResult())
status_subtotal[name] = total_count
return tags
开发者ID:tkdchen,项目名称:Nitrate,代码行数:12,代码来源:data.py
示例6: runs_subtotal_groupby_builds
def runs_subtotal_groupby_builds(self, form):
sql, params = self._prepare_sql(
form, sqls.by_case_run_tester_runs_subtotal_groupby_build)
sql_executor = SQLExecution(sql, params,
with_field_name=False)
rows = sql_executor.rows
builds = GroupByResult({})
for build_id, tested_by_id, total_count in rows:
tested_by_ids = builds.setdefault(build_id, GroupByResult({}))
tested_by_ids[tested_by_id] = total_count
return builds
开发者ID:tkdchen,项目名称:Nitrate,代码行数:14,代码来源:data.py
示例7: status_matrix_groupby_builds
def status_matrix_groupby_builds(self, form):
sql, params = self._prepare_sql(
form, sqls.by_case_run_tester_status_matrix_groupby_build)
sql_executor = SQLExecution(sql, params,
with_field_name=False)
builds = GroupByResult({})
for build_id, tested_by_id, name, total_count in sql_executor.rows:
tested_by_ids = builds.setdefault(
build_id, GroupByResult({}))
status_subtotal = tested_by_ids.setdefault(tested_by_id,
GroupByResult({}))
status_subtotal[name] = total_count
return builds
开发者ID:tkdchen,项目名称:Nitrate,代码行数:16,代码来源:data.py
示例8: setUp
def setUp(self):
self.groupby_result = GroupByResult({
1: 100,
2: 300,
4: 400,
})
self.nested_groupby_result = GroupByResult({
1: GroupByResult({'a': 1,
'b': 2,
'c': 3}),
2: GroupByResult({1: 1,
2: 2}),
3: GroupByResult({'PASSED': 10,
'WAIVED': 20,
'FAILED': 30,
'PAUSED': 40}),
})
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:18,代码来源:tests.py
示例9: runs_subtotal_groupby_builds
def runs_subtotal_groupby_builds(self, form):
builds = GroupByResult({})
query = self._filter_query(
form,
TestCaseRun.objects.values('tested_by', 'run', 'build').distinct()
)
for row in query:
build_id = row['build']
tested_by_id = row['tested_by']
tested_by_ids = builds.setdefault(build_id, GroupByResult({}))
if tested_by_id in tested_by_ids.keys():
tested_by_ids[tested_by_id] += 1
else:
tested_by_ids[tested_by_id] = 1
return builds
开发者ID:MrSenko,项目名称:Nitrate,代码行数:18,代码来源:data.py
示例10: GroupByResultCalculationTest
class GroupByResultCalculationTest(TestCase):
'''Test calculation of GroupByResult'''
def setUp(self):
self.groupby_result = GroupByResult({
1: 100,
2: 300,
4: 400,
})
self.nested_groupby_result = GroupByResult({
1: GroupByResult({'a': 1,
'b': 2,
'c': 3}),
2: GroupByResult({1: 1,
2: 2}),
3: GroupByResult({'PASSED': 10,
'WAIVED': 20,
'FAILED': 30,
'PAUSED': 40}),
})
def _sample_total(self):
return sum(count for key, count in self.groupby_result.iteritems())
def _sample_nested_total(self):
total = 0
for key, nested_result in self.nested_groupby_result.iteritems():
for n, count in nested_result.iteritems():
total += count
return total
def test_total(self):
total = self.groupby_result.total
self.assertEqual(total, self._sample_total())
def test_nested_total(self):
total = self.nested_groupby_result.total
self.assertEqual(total, self._sample_nested_total())
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:39,代码来源:tests.py
示例11: GroupByResultDictLikeTest
class GroupByResultDictLikeTest(TestCase):
'''Test dict like behaviors'''
def setUp(self):
self.groupby_result = GroupByResult({'total': 100})
def test_in(self):
self.assert_('a' not in self.groupby_result)
self.assert_('total' in self.groupby_result)
def test_key(self):
self.assert_(self.groupby_result.keys(), ['total'])
def test_setdefault(self):
ret_val = self.groupby_result.setdefault('count', {})
self.assertEqual(ret_val, {})
ret_val = self.groupby_result.setdefault('total', 200)
self.assertEqual(ret_val, 100)
def test_getitem(self):
ret_val = self.groupby_result['total']
self.assertEqual(ret_val, 100)
try:
ret_val = self.groupby_result['xxx']
except KeyError:
pass
else:
self.fail('xxx does not exist. KeyError should be raised.')
def test_setitem(self):
self.groupby_result['count'] = 200
self.assertEqual(self.groupby_result['count'], 200)
self.groupby_result['total'] = 999
self.assertEqual(self.groupby_result['total'], 999)
def test_get(self):
ret_val = self.groupby_result.get('total')
self.assertEqual(ret_val, 100)
ret_val = self.groupby_result.get('count', 999)
self.assertEqual(ret_val, 999)
ret_val = self.groupby_result.get('xxx')
self.assertEqual(ret_val, None)
def test_len(self):
self.assertEqual(len(self.groupby_result), 1)
def test_del(self):
self.groupby_result['count'] = 200
del self.groupby_result['total']
self.assert_('total' not in self.groupby_result)
del self.groupby_result['count']
self.assert_('count' not in self.groupby_result)
self.assertEqual(len(self.groupby_result), 0)
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:58,代码来源:tests.py
示例12: passed_failed_case_runs_subtotal
def passed_failed_case_runs_subtotal(self, form):
query = self._filter_query(
form,
TestCaseRun.objects.values(
'run__plan__tag', 'case_run_status__name'
).filter(case_run_status__name__in=['PASSED', 'FAILED']).annotate(
total_count=Count('case_run_status')
)
)
tags = GroupByResult()
for row in query:
tag_id = row['run__plan__tag']
name = row['case_run_status__name']
total_count = row['total_count']
status_subtotal = tags.setdefault(tag_id, GroupByResult())
status_subtotal[name] = total_count
from pprint import pprint
pprint(tags)
return tags
开发者ID:MrSenko,项目名称:Nitrate,代码行数:23,代码来源:data.py
示例13: GroupByResultDictLikeTest
class GroupByResultDictLikeTest(unittest.TestCase):
"""Test dict like behaviors"""
def setUp(self):
self.groupby_result = GroupByResult({'total': 100})
def test_in(self):
self.assertNotIn('a', self.groupby_result)
self.assertIn('total', self.groupby_result)
def test_key(self):
self.assertTrue(self.groupby_result.keys(), ['total'])
def test_setdefault(self):
ret_val = self.groupby_result.setdefault('count', {})
self.assertEqual(ret_val, {})
ret_val = self.groupby_result.setdefault('total', 200)
self.assertEqual(ret_val, 100)
def test_setitem(self):
self.groupby_result['count'] = 200
self.assertEqual(self.groupby_result['count'], 200)
self.groupby_result['total'] = 999
self.assertEqual(self.groupby_result['total'], 999)
def test_get(self):
ret_val = self.groupby_result.get('total')
self.assertEqual(ret_val, 100)
ret_val = self.groupby_result.get('count', 999)
self.assertEqual(ret_val, 999)
ret_val = self.groupby_result.get('xxx')
self.assertEqual(ret_val, None)
def test_len(self):
self.assertEqual(len(self.groupby_result), 1)
def test_del(self):
self.groupby_result['count'] = 200
del self.groupby_result['total']
self.assertNotIn('total', self.groupby_result)
del self.groupby_result['count']
self.assertNotIn('count', self.groupby_result)
self.assertEqual(len(self.groupby_result), 0)
开发者ID:tkdchen,项目名称:Nitrate,代码行数:47,代码来源:test_core.py
示例14: GroupByResultCalculationTest
class GroupByResultCalculationTest(unittest.TestCase):
"""Test calculation of GroupByResult"""
def setUp(self):
self.groupby_result = GroupByResult({
1: 100,
2: 300,
4: 400,
})
self.nested_groupby_result = GroupByResult({
1: GroupByResult({'a': 1,
'b': 2,
'c': 3}),
2: GroupByResult({1: 1,
2: 2}),
3: GroupByResult({'PASSED': 10,
'WAIVED': 20,
'FAILED': 30,
'PAUSED': 40}),
})
def _sample_total(self):
return sum(count for key, count in self.groupby_result.iteritems())
def _sample_nested_total(self):
total = 0
for key, nested_result in self.nested_groupby_result.iteritems():
for n, count in nested_result.iteritems():
total += count
return total
def test_total(self):
total = self.groupby_result.total
self.assertEqual(total, self._sample_total())
def test_nested_total(self):
total = self.nested_groupby_result.total
self.assertEqual(total, self._sample_nested_total())
def test_get_total_after_add_data_based_on_empty_initial_data(self):
result = GroupByResult()
result['RUNNING'] = 100
result['PASSED'] = 100
self.assertEqual(200, result.total)
def test_get_total_after_add_data_based_on_initial_data(self):
result = GroupByResult({'FAILED': 20})
result['RUNNING'] = 100
result['PASSED'] = 100
self.assertEqual(220, result.total)
def test_total_is_updated_after_del_item(self):
result = GroupByResult({'FAILED': 20, 'RUNNING': 20, 'PASSED': 10})
del result['RUNNING']
self.assertEqual(30, result.total)
def test_total_is_updated_after_del_item_several_times(self):
result = GroupByResult({'FAILED': 20, 'RUNNING': 20, 'PASSED': 10})
del result['RUNNING']
del result['FAILED']
self.assertEqual(10, result.total)
def test_percentage(self):
result = GroupByResult({
'IDLE': 20,
'PASSED': 20,
'RUNNING': 10,
})
self.assertEqual(40.0, result.PASSED_percent)
def test_zero_percentage(self):
result = GroupByResult({})
self.assertEqual(.0, result.PASSED_percent)
def test_default_zero(self):
result = GroupByResult()
result['RUNNING'] += 1
self.assertEqual(1, result['RUNNING'])
开发者ID:tkdchen,项目名称:Nitrate,代码行数:79,代码来源:test_core.py
示例15: GroupByResultLevelTest
class GroupByResultLevelTest(TestCase):
def setUp(self):
self.levels_groupby_result = GroupByResult({
'build_1': GroupByResult({
'plan_1': GroupByResult({
'run_1': GroupByResult(
{'passed': 1, 'failed': 2, 'error': 3, }),
'run_2': GroupByResult(
{'passed': 1, 'failed': 2, 'error': 3, }),
'run_3': GroupByResult(
{'passed': 1, 'failed': 2, 'error': 3, }),
}),
'plan_2': GroupByResult({
'run_1': GroupByResult(
{'passed': 1, 'failed': 2, 'error': 3, }),
'run_2': GroupByResult(
{'passed': 1, 'failed': 2, 'error': 3, }),
}),
}),
'build_2': GroupByResult({
'plan_1': GroupByResult({
'run_1': GroupByResult(
{'passed': 1, 'failed': 2, 'error': 3, }),
'run_4': GroupByResult(
{'paused': 2, 'failed': 2, 'waived': 6, }),
'run_5': GroupByResult(
{'paused': 1, 'failed': 2, 'waived': 3, }),
}),
'plan_2': GroupByResult({
'run_1': GroupByResult(
{'passed': 1, 'failed': 2, 'error': 3, }),
'run_4': GroupByResult(
{'paused': 2, 'failed': 2, 'waived': 6, }),
'run_5': GroupByResult(
{'paused': 1, 'failed': 2, 'waived': 3, }),
}),
}),
})
def test_value_leaf_count(self):
value_leaf_count = self.levels_groupby_result.leaf_values_count()
self.assertEqual(value_leaf_count, 33)
value_leaf_count = self.levels_groupby_result[
'build_1'].leaf_values_count()
self.assertEqual(value_leaf_count, 15)
level_node = self.levels_groupby_result['build_2']['plan_2']
value_leaf_count = level_node.leaf_values_count()
self.assertEqual(value_leaf_count, 9)
def test_value_leaf_in_row_count(self):
value_leaf_count = self.levels_groupby_result.leaf_values_count(
value_in_row=True)
self.assertEqual(value_leaf_count, 11)
level_node = self.levels_groupby_result['build_2']
value_leaf_count = level_node.leaf_values_count(value_in_row=True)
self.assertEqual(value_leaf_count, 6)
level_node = self.levels_groupby_result['build_1']['plan_2']
value_leaf_count = level_node.leaf_values_count(value_in_row=True)
self.assertEqual(value_leaf_count, 2)
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:63,代码来源:tests.py
注:本文中的tcms.core.db.GroupByResult类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论