Merge lp:~sylvain-pineau/checkbox/xlsx_exporter_new_categories into lp:checkbox

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: no longer in the source branch.
Merged at revision: 3448
Proposed branch: lp:~sylvain-pineau/checkbox/xlsx_exporter_new_categories
Merge into: lp:checkbox
Diff against target: 147 lines (+61/-4)
4 files modified
plainbox/plainbox/impl/exporter/__init__.py (+2/-0)
plainbox/plainbox/impl/exporter/test_init.py (+4/-0)
plainbox/plainbox/impl/exporter/xlsx.py (+46/-4)
plainbox/plainbox/impl/unit/job.py (+9/-0)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/xlsx_exporter_new_categories
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Needs Fixing
Sylvain Pineau Approve
Review via email: mp+243163@code.launchpad.net

Description of the change

This MR allows the xlsx exporter to understand the categories proposed by the new units format as can be seen in the new touch provider.

See: http://people.canonical.com/~spineau/test.xlsx

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

self-approved

review: Approve
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

I'm pretty unhappy about landing that just like that.

- The commit message is lacking, you could have made separate commits for this
- The feature is questionable, it seems that we're *AGAIN* using internal identifiers for dislay where we *ALREADY* have better data. Why are we doing that?
- Some coding below is odd but that's a lesser thing

In general I blame the deadline for the demo on Monday. I really don't like patches that show up, self-approved, on Friday before a demo Monday. Sigh.

Please patch this.

review: Needs Fixing
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Update, looking at the history I see there were separate commits. I'm sorry, launchpad's means of displaying merged branches is just broken. The remainder of my comment stands though.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plainbox/plainbox/impl/exporter/__init__.py'
2--- plainbox/plainbox/impl/exporter/__init__.py 2014-09-17 19:12:22 +0000
3+++ plainbox/plainbox/impl/exporter/__init__.py 2014-11-28 16:02:18 +0000
4@@ -198,6 +198,8 @@
5 continue
6 data['result_map'][job_id] = OrderedDict()
7 data['result_map'][job_id]['summary'] = job_state.job.summary
8+ data['result_map'][job_id]['category_id'] = \
9+ job_state.job.partial_category_id
10 data['result_map'][job_id]['outcome'] = job_state.result.outcome
11 if job_state.result.execution_duration:
12 data['result_map'][job_id]['execution_duration'] = \
13
14=== modified file 'plainbox/plainbox/impl/exporter/test_init.py'
15--- plainbox/plainbox/impl/exporter/test_init.py 2014-05-21 10:36:42 +0000
16+++ plainbox/plainbox/impl/exporter/test_init.py 2014-11-28 16:02:18 +0000
17@@ -133,10 +133,12 @@
18 'result_map': {
19 'job_a': OrderedDict([
20 ('summary', 'job_a'),
21+ ('category_id', 'uncategorised'),
22 ('outcome', 'pass')
23 ]),
24 'job_b': OrderedDict([
25 ('summary', 'job_b'),
26+ ('category_id', 'uncategorised'),
27 ('outcome', 'fail')
28 ])
29 }
30@@ -201,6 +203,7 @@
31 'result_map': {
32 'job_a': OrderedDict([
33 ('summary', 'This is job A'),
34+ ('category_id', 'uncategorised'),
35 ('outcome', 'pass'),
36 ('comments', None),
37 ('via', None),
38@@ -213,6 +216,7 @@
39 ]),
40 'job_b': OrderedDict([
41 ('summary', 'This is job B'),
42+ ('category_id', 'uncategorised'),
43 ('outcome', 'pass'),
44 ('comments', 'foo'),
45 ('via', None),
46
47=== modified file 'plainbox/plainbox/impl/exporter/xlsx.py'
48--- plainbox/plainbox/impl/exporter/xlsx.py 2014-10-14 22:26:02 +0000
49+++ plainbox/plainbox/impl/exporter/xlsx.py 2014-11-28 16:02:18 +0000
50@@ -423,7 +423,44 @@
51 ):
52 result_map[parent]['category_status'] = IJobResult.OUTCOME_SKIP
53
54- def _tree(self, result_map, via=None, level=0, max_level=0):
55+ def _tree(self, result_map):
56+ res = {}
57+ tmp_result_map = {}
58+ for job_name in result_map:
59+ if re.search(
60+ 'resource|attachment',
61+ result_map[job_name]['plugin']):
62+ continue
63+ category = result_map[job_name]['category_id']
64+ if category not in res:
65+ tmp_result_map[category] = {}
66+ tmp_result_map[category]['category_status'] = None
67+ tmp_result_map[category]['plugin'] = 'local'
68+ tmp_result_map[category]['summary'] = category
69+ res[category] = {}
70+ res[category][job_name] = {}
71+ # Generate categories status
72+ child_status = result_map[job_name]['outcome']
73+ if child_status == IJobResult.OUTCOME_FAIL:
74+ tmp_result_map[category]['category_status'] = \
75+ IJobResult.OUTCOME_FAIL
76+ elif (
77+ child_status == IJobResult.OUTCOME_PASS and
78+ tmp_result_map[category]['category_status'] !=
79+ IJobResult.OUTCOME_FAIL
80+ ):
81+ tmp_result_map[category]['category_status'] = \
82+ IJobResult.OUTCOME_PASS
83+ elif (
84+ tmp_result_map[category]['category_status'] not in
85+ (IJobResult.OUTCOME_PASS, IJobResult.OUTCOME_FAIL)
86+ ):
87+ tmp_result_map[category]['category_status'] = \
88+ IJobResult.OUTCOME_SKIP
89+ result_map.update(tmp_result_map)
90+ return res, 2
91+
92+ def _legacy_tree(self, result_map, via=None, level=0, max_level=0):
93 res = {}
94 for job_name in [j for j in result_map if result_map[j]['via'] == via]:
95 if re.search(
96@@ -434,7 +471,7 @@
97 # Find the maximum depth of the test tree
98 if level > max_level:
99 max_level = level
100- res[job_name], max_level = self._tree(
101+ res[job_name], max_level = self._legacy_tree(
102 result_map, result_map[job_name]['hash'], level, max_level)
103 # Generate parent categories status
104 if via is not None:
105@@ -476,7 +513,9 @@
106 if self.OPTION_WITH_DESCRIPTION in self._option_list:
107 self.worksheet4.write(
108 self._lineno, level + 1,
109- result_map[job].get('description', ""), self.format15)
110+ result_map[job].get(
111+ 'description',
112+ result_map[job].get('summary', "")), self.format15)
113 if level:
114 self.worksheet3.set_row(
115 self._lineno, 13, None, {'level': level})
116@@ -574,7 +613,10 @@
117 self._lineno, 12 + 10.5 * desc_lines)
118
119 def write_results(self, data):
120- tree, max_level = self._tree(data['result_map'])
121+ if [k for k, v in data['result_map'].items() if 'category_id' in v]:
122+ tree, max_level = self._tree(data['result_map'])
123+ else:
124+ tree, max_level = self._legacy_tree(data['result_map'])
125 self.worksheet3.write(3, 1, _('Tests Performed'), self.format03)
126 self.worksheet3.freeze_panes(6, 0)
127 self.worksheet3.set_tab_color('#DC4C00') # Orange
128
129=== modified file 'plainbox/plainbox/impl/unit/job.py'
130--- plainbox/plainbox/impl/unit/job.py 2014-11-25 11:33:53 +0000
131+++ plainbox/plainbox/impl/unit/job.py 2014-11-28 16:02:18 +0000
132@@ -304,6 +304,15 @@
133 'category_id', '2013.com.canonical.plainbox::uncategorised'))
134
135 @property
136+ def partial_category_id(self):
137+ """
138+ Identifier of this job category, without the provider name
139+
140+ This field should not be used anymore, except for display
141+ """
142+ return self.get_record_value('category_id', 'uncategorised')
143+
144+ @property
145 def estimated_duration(self):
146 """
147 estimated duration of this job in seconds.

Subscribers

People subscribed via source and target branches