VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/webui/wuiadmintestcase.py@ 61255

Last change on this file since 61255 was 61255, checked in by vboxsync, 9 years ago

testmanager: two database changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.8 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: wuiadmintestcase.py 61255 2016-05-28 03:52:35Z vboxsync $
3
4"""
5Test Manager WUI - Test Cases.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2012-2015 Oracle Corporation
11
12This file is part of VirtualBox Open Source Edition (OSE), as
13available from http://www.virtualbox.org. This file is free software;
14you can redistribute it and/or modify it under the terms of the GNU
15General Public License (GPL) as published by the Free Software
16Foundation, in version 2 as it comes in the "COPYING" file of the
17VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
20The contents of this file may alternatively be used under the terms
21of the Common Development and Distribution License Version 1.0
22(CDDL) only, as it comes in the "COPYING.CDDL" file of the
23VirtualBox OSE distribution, in which case the provisions of the
24CDDL are applicable instead of those of the GPL.
25
26You may elect to license modified versions of this file under the
27terms and conditions of either the GPL or the CDDL or both.
28"""
29__version__ = "$Revision: 61255 $"
30
31
32# Validation Kit imports.
33from common import utils, webutils;
34from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink, WuiRawHtml;
35from testmanager.core.db import isDbTimestampInfinity;
36from testmanager.core.testcase import TestCaseDataEx, TestCaseData, TestCaseDependencyLogic;
37from testmanager.core.globalresource import GlobalResourceData, GlobalResourceLogic;
38
39class WuiTestCaseList(WuiListContentBase):
40 """
41 WUI test case list content generator.
42 """
43
44 def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp):
45 WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
46 sTitle = 'Test Cases', fnDPrint = fnDPrint, oDisp = oDisp);
47 self._asColumnHeaders = \
48 [
49 'Name', 'Active', 'Default Timeout', 'Base Command / Variations', 'Validation Kit Files',
50 'Test Case Prereqs', 'Global Resources', 'Actions'
51 ];
52 self._asColumnAttribs = \
53 [
54 '', '', '', '', '',
55 'valign="top"', 'valign="top"', 'align="center"'
56 ];
57
58 def _formatListEntry(self, iEntry):
59 oEntry = self._aoEntries[iEntry];
60 from testmanager.webui.wuiadmin import WuiAdmin;
61
62 aoRet = \
63 [
64 oEntry.sName.replace('-', u'\u2011'),
65 'Enabled' if oEntry.fEnabled else 'Disabled',
66 utils.formatIntervalSeconds(oEntry.cSecTimeout),
67 ];
68
69 # Base command and variations.
70 fNoGang = True;
71 fNoSubName = True;
72 fAllDefaultTimeouts = True;
73 for oVar in oEntry.aoTestCaseArgs:
74 if fNoSubName and oVar.sSubName is not None and len(oVar.sSubName.strip()) > 0:
75 fNoSubName = False;
76 if oVar.cGangMembers > 1:
77 fNoGang = False;
78 if oVar.cSecTimeout is not None:
79 fAllDefaultTimeouts = False;
80
81 sHtml = ' <table class="tminnertbl" width=100%>\n' \
82 ' <tr>\n' \
83 ' ';
84 if not fNoSubName:
85 sHtml += '<th class="tmtcasubname">Sub-name</th>';
86 if not fNoGang:
87 sHtml += '<th class="tmtcagangsize">Gang Size</th>';
88 if not fAllDefaultTimeouts:
89 sHtml += '<th class="tmtcatimeout">Timeout</th>';
90 sHtml += '<th>Additional Arguments</b></th>\n' \
91 ' </tr>\n'
92 for oTmp in oEntry.aoTestCaseArgs:
93 sHtml += '<tr>';
94 if not fNoSubName:
95 sHtml += '<td>%s</td>' % (webutils.escapeElem(oTmp.sSubName) if oTmp.sSubName is not None else '');
96 if not fNoGang:
97 sHtml += '<td>%d</td>' % (oTmp.cGangMembers,)
98 if not fAllDefaultTimeouts:
99 sHtml += '<td>%s</td>' \
100 % (utils.formatIntervalSeconds(oTmp.cSecTimeout) if oTmp.cSecTimeout is not None else 'Default',)
101 sHtml += u'<td>%s</td></tr>' \
102 % ( webutils.escapeElem(oTmp.sArgs.replace('-', u'\u2011')) if len(oTmp.sArgs) > 0 else u'\u2011',);
103 sHtml += '</tr>\n';
104 sHtml += ' </table>'
105
106 aoRet.append([oEntry.sBaseCmd.replace('-', u'\u2011'), WuiRawHtml(sHtml)]);
107
108 # Next.
109 aoRet += [ oEntry.sValidationKitZips if oEntry.sValidationKitZips is not None else '', ];
110
111 # Show dependency on other testcases
112 if oEntry.aoDepTestCases not in (None, []):
113 sHtml = ' <ul class="tmshowall">\n'
114 for sTmp in oEntry.aoDepTestCases:
115 sHtml += ' <li class="tmshowall"><a href="%s?%s=%s&%s=%s">%s</a></li>\n' \
116 % (WuiAdmin.ksScriptName,
117 WuiAdmin.ksParamAction, WuiAdmin.ksActionTestCaseEdit,
118 TestCaseData.ksParam_idTestCase, sTmp.idTestCase,
119 sTmp.sName)
120 sHtml += ' </ul>\n'
121 else:
122 sHtml = '<ul class="tmshowall"><li class="tmshowall">None</li></ul>\n'
123 aoRet.append(WuiRawHtml(sHtml));
124
125 # Show dependency on global resources
126 if oEntry.aoDepGlobalResources not in (None, []):
127 sHtml = ' <ul class="tmshowall">\n'
128 for sTmp in oEntry.aoDepGlobalResources:
129 sHtml += ' <li class="tmshowall"><a href="%s?%s=%s&%s=%s">%s</a></li>\n' \
130 % (WuiAdmin.ksScriptName,
131 WuiAdmin.ksParamAction, WuiAdmin.ksActionGlobalRsrcShowEdit,
132 GlobalResourceData.ksParam_idGlobalRsrc, sTmp.idGlobalRsrc,
133 sTmp.sName)
134 sHtml += ' </ul>\n'
135 else:
136 sHtml = '<ul class="tmshowall"><li class="tmshowall">None</li></ul>\n'
137 aoRet.append(WuiRawHtml(sHtml));
138
139 # Show actions that can be taken.
140 aoActions = [ WuiTmLink('Details', WuiAdmin.ksScriptName,
141 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestCaseDetails,
142 TestCaseData.ksParam_idGenTestCase: oEntry.idGenTestCase }), ];
143 if isDbTimestampInfinity(oEntry.tsExpire):
144 aoActions.append(WuiTmLink('Modify', WuiAdmin.ksScriptName,
145 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestCaseEdit,
146 TestCaseData.ksParam_idTestCase: oEntry.idTestCase }));
147 aoActions.append(WuiTmLink('Clone', WuiAdmin.ksScriptName,
148 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestCaseClone,
149 TestCaseData.ksParam_idGenTestCase: oEntry.idGenTestCase }));
150 if isDbTimestampInfinity(oEntry.tsExpire):
151 aoActions.append(WuiTmLink('Remove', WuiAdmin.ksScriptName,
152 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestCaseDoRemove,
153 TestCaseData.ksParam_idTestCase: oEntry.idTestCase },
154 sConfirm = 'Are you sure you want to remove test case #%d?' % (oEntry.idTestCase,)));
155 aoRet.append(aoActions);
156
157 return aoRet;
158
159
160class WuiTestCase(WuiFormContentBase):
161 """
162 WUI user account content generator.
163 """
164
165 def __init__(self, oData, sMode, oDisp):
166 assert isinstance(oData, TestCaseDataEx);
167
168 if sMode == WuiFormContentBase.ksMode_Add:
169 sTitle = 'New Test Case';
170 elif sMode == WuiFormContentBase.ksMode_Edit:
171 sTitle = 'Edit Test Case - %s (#%s)' % (oData.sName, oData.idTestCase);
172 else:
173 assert sMode == WuiFormContentBase.ksMode_Show;
174 sTitle = 'Test Case - %s (#%s)' % (oData.sName, oData.idTestCase);
175 WuiFormContentBase.__init__(self, oData, sMode, 'TestCase', oDisp, sTitle);
176
177 # Read additional bits form the DB.
178 oDepLogic = TestCaseDependencyLogic(oDisp.getDb());
179 self._aoAllTestCases = oDepLogic.getApplicableDepTestCaseData(-1 if oData.idTestCase is None else oData.idTestCase);
180 self._aoAllGlobalRsrcs = GlobalResourceLogic(oDisp.getDb()).getAll();
181
182 def _populateForm(self, oForm, oData):
183 oForm.addIntRO (TestCaseData.ksParam_idTestCase, oData.idTestCase, 'Test Case ID')
184 oForm.addTimestampRO(TestCaseData.ksParam_tsEffective, oData.tsEffective, 'Last changed')
185 oForm.addTimestampRO(TestCaseData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)')
186 oForm.addIntRO (TestCaseData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID')
187 oForm.addIntRO (TestCaseData.ksParam_idGenTestCase, oData.idGenTestCase, 'Test Case generation ID')
188 oForm.addText (TestCaseData.ksParam_sName, oData.sName, 'Name')
189 oForm.addText (TestCaseData.ksParam_sDescription, oData.sDescription, 'Description')
190 oForm.addCheckBox (TestCaseData.ksParam_fEnabled, oData.fEnabled, 'Enabled')
191 oForm.addLong (TestCaseData.ksParam_cSecTimeout,
192 utils.formatIntervalSeconds2(oData.cSecTimeout), 'Default timeout')
193 oForm.addWideText (TestCaseData.ksParam_sTestBoxReqExpr, oData.sTestBoxReqExpr, 'TestBox requirements (python)');
194 oForm.addWideText (TestCaseData.ksParam_sBuildReqExpr, oData.sBuildReqExpr, 'Build requirement (python)');
195 oForm.addWideText (TestCaseData.ksParam_sBaseCmd, oData.sBaseCmd, 'Base command')
196 oForm.addText (TestCaseData.ksParam_sValidationKitZips, oData.sValidationKitZips, 'Test suite files')
197
198 oForm.addListOfTestCaseArgs(TestCaseDataEx.ksParam_aoTestCaseArgs, oData.aoTestCaseArgs, 'Argument variations')
199
200 aoTestCaseDeps = [];
201 for oTestCase in self._aoAllTestCases:
202 if oTestCase.idTestCase == oData.idTestCase:
203 continue;
204 fSelected = False;
205 for oDep in oData.aoDepTestCases:
206 if oDep.idTestCase == oTestCase.idTestCase:
207 fSelected = True;
208 break;
209 aoTestCaseDeps.append([oTestCase.idTestCase, fSelected, oTestCase.sName]);
210 oForm.addListOfTestCases(TestCaseDataEx.ksParam_aoDepTestCases, aoTestCaseDeps, 'Depends on test cases')
211
212 aoGlobalResrcDeps = [];
213 for oGlobalRsrc in self._aoAllGlobalRsrcs:
214 fSelected = False;
215 for oDep in oData.aoDepGlobalResources:
216 if oDep.idGlobalRsrc == oGlobalRsrc.idGlobalRsrc:
217 fSelected = True;
218 break;
219 aoGlobalResrcDeps.append([oGlobalRsrc.idGlobalRsrc, fSelected, oGlobalRsrc.sName]);
220 oForm.addListOfResources(TestCaseDataEx.ksParam_aoDepGlobalResources, aoGlobalResrcDeps, 'Depends on resources')
221
222 oForm.addSubmit();
223
224 return True;
225
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette