Switch TestExecution tables to new table views (closes #1965435)

Use three variants:
- with all columns
- with everything but the PE, for use in PE executions tab and project
test reports tab
- with everything but the TC, for use in TC executions tab

authorJulien Cristau <julien.cristau@logilab.fr>
changeset83292caad00c
branchstable
phasepublic
hiddenno
parent revision#8c0027f1a811 Escape <> in TestExecution outofcontext view (closes #2127106)
child revision#35bdc8c657d6 2.2.1
files modified by this revision
views/primary.py
views/testexecution.py
views/tracker.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1324551983 -3600
# Thu Dec 22 12:06:23 2011 +0100
# Branch stable
# Node ID 83292caad00c609575938fccd753442b054cf15e
# Parent 8c0027f1a811742028d8922a8e13d4669c22dd06
Switch TestExecution tables to new table views (closes #1965435)

Use three variants:
- with all columns
- with everything but the PE, for use in PE executions tab and project
test reports tab
- with everything but the TC, for use in TC executions tab

diff --git a/views/primary.py b/views/primary.py
@@ -133,18 +133,18 @@
1      __select__ = (is_instance('ProjectEnvironment') &
2                    has_related_entities('using_environment', 'object'))
3 
4      html_headers = no_robot_index
5 
6 -    def cell_call(self, row, col):
7 +    def entity_call(self, entity):
8          rset = self._cw.execute(
9              'Any T,TC,T,TB,TST,TET,TF, TS ORDERBY TST DESC WHERE '
10              'T status TS, T using_config TC, T branch TB, '
11              'T starttime TST, T endtime TET, T log_file TF?, '
12              'T using_environment PE, PE eid %(pe)s',
13 -            {'pe': self.cw_rset[row][col]})
14 -        self.wview('apycot.te.summarytable', rset, 'noresult', showpe=False)
15 +            {'pe': entity.eid})
16 +        self.wview('apycot.te.nopetable', rset, 'noresult')
17 
18 
19  class PETestConfigView(EntityView):
20      __regid__ = 'apycot.pe.tc'
21      __select__ = (is_instance('ProjectEnvironment')
@@ -244,18 +244,18 @@
22                    has_related_entities('using_config', 'object'))
23      __regid__ = 'narval.recipe.tab_executions'
24 
25      html_headers = no_robot_index
26 
27 -    def cell_call(self, row, col):
28 +    def entity_call(self, entity):
29          rset = self._cw.execute(
30              'Any T,PE,T,TB,TST,TET,TF, TS,PEN ORDERBY TST DESC WHERE '
31              'T status TS, T using_config TC, T using_environment PE, '
32              'T branch TB, T starttime TST, T endtime TET, T log_file TF?, '
33              'PE name PEN, TC eid %(tc)s',
34 -            {'tc': self.cw_rset[row][col]})
35 -        self.wview('apycot.tc.te.summarytable', rset, 'noresult')
36 +            {'tc': entity.eid})
37 +        self.wview('apycot.te.notctable', rset, 'noresult')
38 
39 
40  class TCStartModeView(EntityView):
41      __regid__ = 'apycot.tc.startmode'
42      __select__ = is_instance('TestConfig') & match_kwargs('rtype')
@@ -266,29 +266,10 @@
43          self.w(tconfig.printable_value('computed_start_mode'))
44          if tconfig.start_mode == 'inherited':
45              self.w(self._cw._(' (inherited)'))
46 
47 
48 -class TCTESummaryTable(tableview.TableView):
49 -    __select__ = is_instance('TestExecution')
50 -    __regid__ = 'apycot.tc.te.summarytable'
51 -
52 -    html_headers = no_robot_index
53 -
54 -    def call(self):
55 -        self._cw.add_css('cubes.apycot.css')
56 -        _ = self._cw._
57 -        super(TCTESummaryTable, self).call(
58 -            displayfilter=True, paginate=True,
59 -            headers=[_('TestExecution'), _('ProjectEnvironment'),
60 -                     _('checks'), _('branch'),
61 -                     _('starttime'), _('endtime'), _('archive')],
62 -            cellvids={0: 'apycot.te.statuscell',
63 -                      2: 'apycot.te.summarycell',
64 -                      6: 'icon'})
65 -
66 -
67  def _available_branches(form, field):
68      tc = form.edited_entity
69      environment = form.cw_extra_kwargs['environment']
70      # if branch specified on the environment, don't let other choices
71      envcfg = environment.apycot_configuration()
diff --git a/views/testexecution.py b/views/testexecution.py
@@ -96,46 +96,63 @@
72              w(u'</dl>')
73 
74 
75  # TestExecution ################################################################
76 
77 -class TESummaryTable(tableview.TableView):
78 +class TESummaryTable(EntityView):
79      __regid__ = 'apycot.te.summarytable'
80      __select__ = is_instance('TestExecution') | none_rset()
81 -
82 -    html_headers = no_robot_index
83      title = _('Apycot executions')
84      category = 'startupview'
85 
86 -    def call(self, showpe=True):
87 -        self._cw.add_css('cubes.apycot.css')
88 -        _ = self._cw._
89 +    html_headers = no_robot_index
90 +    default_rql = ('Any T,PE,TC,T,TB,TST,TET,TF, TS ORDERBY TST DESC WHERE '
91 +                   'T status TS, T using_config TC, T using_environment PE, '
92 +                   'T branch TB, T starttime TST, T endtime TET, T log_file TF?')
93 +
94 +    def call(self):
95 +        w = self.w
96 +        req = self._cw
97          if self.cw_rset is None:
98 -            assert showpe
99 -            self.cw_rset = self._cw.execute(
100 -                'Any T,PE,TC,T,TB,TST,TET,TF, TS ORDERBY TST DESC WHERE '
101 -                'T status TS, T using_config TC, T using_environment PE, '
102 -                'T branch TB, T starttime TST, T endtime TET, T log_file TF?')
103 -            self.w('<h1>%s</h1>' % _(self.title))
104 -        if showpe:
105 -            headers = [_('TestExecution'), _('ProjectEnvironment'), _('TestConfig'),
106 -                       _('checks'), _('branch'),
107 -                       _('starttime'), _('endtime'), _('archive')]
108 -            cellvids = {0: 'apycot.te.statuscell',
109 -                        3: 'apycot.te.summarycell',
110 -                        7: 'icon'}
111 -        else:
112 -            headers = [_('TestExecution'), _('TestConfig'),
113 -                       _('checks'), _('branch'),
114 -                       _('starttime'), _('endtime'), _('archive')]
115 -            cellvids = {0: 'apycot.te.statuscell',
116 -                        2: 'apycot.te.summarycell',
117 -                        6: 'icon'}
118 -        displayfilter = self._cw.form.get('displayfilter', True)
119 -        super(TESummaryTable, self).call(displayfilter=displayfilter,
120 -                                         paginate=True,
121 -                                         headers=headers, cellvids=cellvids)
122 +            self.cw_rset = req.execute(self.default_rql)
123 +        self.wview('apycot.te.table', self.cw_rset, 'null')
124 +
125 +
126 +class TETable(tableview.EntityTableView):
127 +    __regid__ = 'apycot.te.table'
128 +    __select__ = is_instance('TestExecution')
129 +
130 +    columns = ['testexecution', 'projectenvironment', 'using_config', 'checks', 'branch', 'starttime', 'endtime', 'log_file']
131 +    column_renderers = {
132 +            'testexecution': tableview.MainEntityColRenderer(
133 +                vid='apycot.te.statuscell'),
134 +            'using_config': tableview.RelatedEntityColRenderer(
135 +                header=_('TestConfig'), getrelated=lambda x: x.configuration),
136 +            'projectenvironment': tableview.RelatedEntityColRenderer(
137 +                header=_('ProjectEnvironment'), getrelated=lambda x: x.environment),
138 +            'checks': tableview.MainEntityColRenderer(
139 +                header=_('checks'), addcount=False, vid='apycot.te.summarycell'),
140 +            'log_file': tableview.RelationColRenderer(
141 +                subvid='icon')
142 +            }
143 +    layout_args = {
144 +            'display_filter': 'top'
145 +            }
146 +
147 +    def call(self, columns=None):
148 +        self._cw.add_css('cubes.apycot.css')
149 +        super(TETable, self).call(columns)
150 +
151 +
152 +class TENoPETable(TETable):
153 +    __regid__ = 'apycot.te.nopetable'
154 +    columns = ['testexecution', 'using_config', 'checks', 'branch', 'starttime', 'endtime', 'log_file']
155 +
156 +
157 +class TENoTCTable(TETable):
158 +    __regid__ = 'apycot.te.notctable'
159 +    columns = ['testexecution', 'projectenvironment', 'checks', 'branch', 'starttime', 'endtime', 'log_file']
160 
161 
162  _pvdc.tag_attribute(('TestExecution', 'priority',), {'vid': 'tasksqueue.priority'}) # XXX rtag inheritance bug
163  _pvs.tag_attribute(('TestExecution', 'execution_log'), 'relations')
164  _pvdc.tag_attribute(('TestExecution', 'execution_log'), {'vid': 'narval.formated_log',
diff --git a/views/tracker.py b/views/tracker.py
@@ -18,18 +18,18 @@
165  class ProjectTestResultsTab(EntityView):
166      """display project's documentation"""
167      __regid__ = title = _('apycottestresults_tab')
168      __select__ = is_instance('Project')
169 
170 -    def cell_call(self, row, col):
171 +    def entity_call(self, entity):
172          rset = self._cw.execute(
173              'Any T,TC,T,TB,TST,TET,TF, TS ORDERBY TST DESC WHERE '
174              'T status TS, T using_config TC, T branch TB, '
175              'T starttime TST, T endtime TET, T log_file TF?, '
176              'T using_environment PE, P has_apycot_environment PE, '
177 -            'P eid %(p)s', {'p': self.cw_rset[row][col]})
178 -        self.wview('apycot.te.summarytable', rset, 'noresult', showpe=False)
179 +            'P eid %(p)s', {'p': entity.eid})
180 +        self.wview('apycot.te.nopetable', rset, 'noresult')
181 
182 
183  # class VersionTestResultsVComponent(component.EntityVComponent):
184  #     """display the latest tests execution results"""
185  #     __regid__ = 'apycottestresults'