VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/webui/wuiadmintestgroup.py

Last change on this file was 106061, checked in by vboxsync, 3 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.7 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: wuiadmintestgroup.py 106061 2024-09-16 14:03:52Z vboxsync $
3
4"""
5Test Manager WUI - Test Groups.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2012-2024 Oracle and/or its affiliates.
11
12This file is part of VirtualBox base platform packages, as
13available from https://www.virtualbox.org.
14
15This program is free software; you can redistribute it and/or
16modify it under the terms of the GNU General Public License
17as published by the Free Software Foundation, in version 3 of the
18License.
19
20This program is distributed in the hope that it will be useful, but
21WITHOUT ANY WARRANTY; without even the implied warranty of
22MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23General Public License for more details.
24
25You should have received a copy of the GNU General Public License
26along with this program; if not, see <https://www.gnu.org/licenses>.
27
28The contents of this file may alternatively be used under the terms
29of the Common Development and Distribution License Version 1.0
30(CDDL), a copy of it is provided in the "COPYING.CDDL" file included
31in the VirtualBox distribution, in which case the provisions of the
32CDDL are applicable instead of those of the GPL.
33
34You may elect to license modified versions of this file under the
35terms and conditions of either the GPL or the CDDL or both.
36
37SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
38"""
39__version__ = "$Revision: 106061 $"
40
41# Validation Kit imports.
42from common import utils, webutils;
43from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink, WuiRawHtml;
44from testmanager.core.db import isDbTimestampInfinity;
45from testmanager.core.testgroup import TestGroupData, TestGroupDataEx;
46from testmanager.core.testcase import TestCaseData, TestCaseLogic;
47
48
49class WuiTestGroup(WuiFormContentBase):
50 """
51 WUI test group content generator.
52 """
53
54 def __init__(self, oData, sMode, oDisp):
55 assert isinstance(oData, TestGroupDataEx);
56
57 if sMode == WuiFormContentBase.ksMode_Add:
58 sTitle = 'Add Test Group';
59 elif sMode == WuiFormContentBase.ksMode_Edit:
60 sTitle = 'Modify Test Group';
61 else:
62 assert sMode == WuiFormContentBase.ksMode_Show;
63 sTitle = 'Test Group';
64 WuiFormContentBase.__init__(self, oData, sMode, 'TestGroup', oDisp, sTitle);
65
66 #
67 # Fetch additional data.
68 #
69 if sMode in [WuiFormContentBase.ksMode_Add, WuiFormContentBase.ksMode_Edit]:
70 self.aoAllTestCases = TestCaseLogic(oDisp.getDb()).fetchForListing(0, 0x7fff, None);
71 else:
72 self.aoAllTestCases = [oMember.oTestCase for oMember in oData.aoMembers];
73
74 def _populateForm(self, oForm, oData):
75 oForm.addIntRO (TestGroupData.ksParam_idTestGroup, self._oData.idTestGroup, 'Test Group ID')
76 oForm.addTimestampRO (TestGroupData.ksParam_tsEffective, self._oData.tsEffective, 'Last changed')
77 oForm.addTimestampRO (TestGroupData.ksParam_tsExpire, self._oData.tsExpire, 'Expires (excl)')
78 oForm.addIntRO (TestGroupData.ksParam_uidAuthor, self._oData.uidAuthor, 'Changed by UID')
79 oForm.addText (TestGroupData.ksParam_sName, self._oData.sName, 'Name')
80 oForm.addText (TestGroupData.ksParam_sDescription, self._oData.sDescription, 'Description')
81
82 oForm.addListOfTestGroupMembers(TestGroupDataEx.ksParam_aoMembers,
83 oData.aoMembers, self.aoAllTestCases, 'Test Case List',
84 fReadOnly = self._sMode == WuiFormContentBase.ksMode_Show);
85
86 oForm.addMultilineText (TestGroupData.ksParam_sComment, self._oData.sComment, 'Comment');
87 oForm.addSubmit();
88 return True;
89
90
91class WuiTestGroupList(WuiListContentBase):
92 """
93 WUI test group list content generator.
94 """
95
96 def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp, aiSelectedSortColumns = None):
97 assert not aoEntries or isinstance(aoEntries[0], TestGroupDataEx)
98
99 WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, sTitle = 'Test Groups',
100 fnDPrint = fnDPrint, oDisp = oDisp, aiSelectedSortColumns = aiSelectedSortColumns);
101 self._asColumnHeaders = [ 'ID', 'Name', 'Description', 'Test Cases', 'Note', 'Actions' ];
102 self._asColumnAttribs = [ 'align="right"', '', '', '', 'align="center"', 'align="center"' ];
103
104
105 def _formatListEntry(self, iEntry):
106 oEntry = self._aoEntries[iEntry];
107 from testmanager.webui.wuiadmin import WuiAdmin;
108
109 #
110 # Test case list.
111 #
112 sHtml = '';
113 if oEntry.aoMembers:
114 for oMember in oEntry.aoMembers:
115 sHtml += '<dl>\n' \
116 ' <dd><strong>%s</strong> (priority: %d) %s %s</dd>\n' \
117 % ( webutils.escapeElem(oMember.oTestCase.sName),
118 oMember.iSchedPriority,
119 WuiTmLink('Details', WuiAdmin.ksScriptName,
120 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestCaseDetails,
121 TestCaseData.ksParam_idGenTestCase: oMember.oTestCase.idGenTestCase, } ).toHtml(),
122 WuiTmLink('Edit', WuiAdmin.ksScriptName,
123 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestCaseEdit,
124 TestCaseData.ksParam_idTestCase: oMember.oTestCase.idTestCase, } ).toHtml()
125 if isDbTimestampInfinity(oMember.oTestCase.tsExpire)
126 and self._oDisp is not None
127 and not self._oDisp.isReadOnlyUser() else '',
128 );
129
130 sHtml += ' <dt>\n';
131
132 fNoGang = True;
133 for oVar in oMember.oTestCase.aoTestCaseArgs:
134 if oVar.cGangMembers > 1:
135 fNoGang = False
136 break;
137
138 sHtml += ' <table class="tminnertbl" width="100%">\n'
139 if fNoGang:
140 sHtml += ' <tr><th>Timeout</th><th>Arguments</th></tr>\n';
141 else:
142 sHtml += ' <tr><th>Gang Size</th><th>Timeout</th><th style="text-align:left;">Arguments</th></tr>\n';
143
144 cArgsIncluded = 0;
145 for oVar in oMember.oTestCase.aoTestCaseArgs:
146 if oMember.aidTestCaseArgs is None or oVar.idTestCaseArgs in oMember.aidTestCaseArgs:
147 cArgsIncluded += 1;
148 if fNoGang:
149 sHtml += ' <tr>';
150 else:
151 sHtml += ' <tr><td>%s</td>' % (oVar.cGangMembers,);
152 sHtml += '<td>%s</td><td>%s</td></tr>\n' \
153 % ( utils.formatIntervalSeconds(oMember.oTestCase.cSecTimeout if oVar.cSecTimeout is None
154 else oVar.cSecTimeout),
155 webutils.escapeElem(oVar.sArgs), );
156 if cArgsIncluded == 0:
157 sHtml += ' <tr><td colspan="%u">No arguments selected.</td></tr>\n' % ( 2 if fNoGang else 3, );
158 sHtml += ' </table>\n' \
159 ' </dl>\n';
160 oTestCases = WuiRawHtml(sHtml);
161
162 #
163 # Actions.
164 #
165 aoActions = [ WuiTmLink('Details', WuiAdmin.ksScriptName,
166 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestGroupDetails,
167 TestGroupData.ksParam_idTestGroup: oEntry.idTestGroup,
168 WuiAdmin.ksParamEffectiveDate: self._tsEffectiveDate, }) ];
169 if self._oDisp is None or not self._oDisp.isReadOnlyUser():
170
171 if isDbTimestampInfinity(oEntry.tsExpire):
172 aoActions.append(WuiTmLink('Modify', WuiAdmin.ksScriptName,
173 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestGroupEdit,
174 TestGroupData.ksParam_idTestGroup: oEntry.idTestGroup }));
175 aoActions.append(WuiTmLink('Clone', WuiAdmin.ksScriptName,
176 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestGroupClone,
177 TestGroupData.ksParam_idTestGroup: oEntry.idTestGroup,
178 WuiAdmin.ksParamEffectiveDate: self._tsEffectiveDate, }));
179 aoActions.append(WuiTmLink('Remove', WuiAdmin.ksScriptName,
180 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestGroupDoRemove,
181 TestGroupData.ksParam_idTestGroup: oEntry.idTestGroup },
182 sConfirm = 'Do you really want to remove test group #%d?' % (oEntry.idTestGroup,)));
183 else:
184 aoActions.append(WuiTmLink('Clone', WuiAdmin.ksScriptName,
185 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestGroupClone,
186 TestGroupData.ksParam_idTestGroup: oEntry.idTestGroup,
187 WuiAdmin.ksParamEffectiveDate: self._tsEffectiveDate, }));
188
189
190
191 return [ oEntry.idTestGroup,
192 oEntry.sName,
193 oEntry.sDescription if oEntry.sDescription is not None else '',
194 oTestCases,
195 self._formatCommentCell(oEntry.sComment, cMaxLines = max(3, len(oEntry.aoMembers) * 2)),
196 aoActions ];
197
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