Conditions | 2 |
Total Lines | 33 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | from django.db.models import Count |
||
7 | @rpc_method(name='Testing.breakdown') |
||
8 | def breakdown(query=None): |
||
9 | """ |
||
10 | .. function:: XML-RPC Testing.breakdown(query) |
||
11 | |||
12 | Perform a search and return the statistics for the selected test cases |
||
13 | |||
14 | :param query: Field lookups for :class:`tcms.testcases.models.TestCase` |
||
15 | :type query: dict |
||
16 | :return: Object, containing the statistics for the selected test cases |
||
17 | :rtype: dict |
||
18 | """ |
||
19 | |||
20 | if query is None: |
||
21 | query = {} |
||
22 | |||
23 | test_cases = TestCase.objects.filter(**query).filter() |
||
24 | |||
25 | manual_count = test_cases.filter(is_automated=False).count() |
||
26 | automated_count = test_cases.filter(is_automated=True).count() |
||
27 | count = { |
||
28 | 'manual': manual_count, |
||
29 | 'automated': automated_count, |
||
30 | 'all': manual_count + automated_count |
||
31 | } |
||
32 | |||
33 | priorities = _get_field_count_map(test_cases, 'priority', 'priority__value') |
||
34 | categories = _get_field_count_map(test_cases, 'category', 'category__name') |
||
35 | |||
36 | return { |
||
37 | 'count': count, |
||
38 | 'priorities': priorities, |
||
39 | 'categories': categories, |
||
40 | } |
||
46 |