VirtualBox

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

Last change on this file since 57761 was 56295, checked in by vboxsync, 10 years ago

ValidationKit: Updated (C) year.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.8 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: wuiadmintestgroup.py 56295 2015-06-09 14:29:55Z vboxsync $
3
4"""
5Test Manager WUI - Test Groups.
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: 56295 $"
30
31# Validation Kit imports.
32from common import utils, webutils;
33from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink, WuiRawHtml;
34from testmanager.core.db import isDbTimestampInfinity;
35from testmanager.core.testgroup import TestGroupData, TestGroupDataEx;
36from testmanager.core.testcase import TestCaseData, TestCaseLogic;
37
38
39class WuiTestGroup(WuiFormContentBase):
40 """
41 WUI test group content generator.
42 """
43
44 def __init__(self, oData, sMode, oDisp):
45 assert isinstance(oData, TestGroupDataEx);
46
47 if sMode == WuiFormContentBase.ksMode_Add:
48 sTitle = 'Add Test Group';
49 elif sMode == WuiFormContentBase.ksMode_Edit:
50 sTitle = 'Modify Test Group';
51 else:
52 assert sMode == WuiFormContentBase.ksMode_Show;
53 sTitle = 'Test Group';
54 WuiFormContentBase.__init__(self, oData, sMode, 'TestGroup', oDisp, sTitle);
55
56 #
57 # Fetch additional data.
58 #
59 if sMode in [WuiFormContentBase.ksMode_Add, WuiFormContentBase.ksMode_Edit]:
60 self.aoAllTestCases = TestCaseLogic(oDisp.getDb()).fetchForListing(0, 0x7fff, None);
61 else:
62 self.aoAllTestCases = [oMember.oTestCase for oMember in oData.aoMembers];
63
64 def _populateForm(self, oForm, oData):
65 oForm.addIntRO (TestGroupData.ksParam_idTestGroup, self._oData.idTestGroup, 'Test Group ID')
66 oForm.addTimestampRO (TestGroupData.ksParam_tsEffective, self._oData.tsEffective, 'Last changed')
67 oForm.addTimestampRO (TestGroupData.ksParam_tsExpire, self._oData.tsExpire, 'Expires (excl)')
68 oForm.addIntRO (TestGroupData.ksParam_uidAuthor, self._oData.uidAuthor, 'Changed by UID')
69 oForm.addText (TestGroupData.ksParam_sName, self._oData.sName, 'Name')
70 oForm.addText (TestGroupData.ksParam_sDescription, self._oData.sDescription, 'Description')
71
72 oForm.addListOfTestGroupMembers(TestGroupDataEx.ksParam_aoMembers,
73 oData.aoMembers, self.aoAllTestCases, 'Test Case List',
74 fReadOnly = self._sMode == WuiFormContentBase.ksMode_Show);
75
76 oForm.addSubmit();
77 return True;
78
79
80class WuiTestGroupList(WuiListContentBase):
81 """
82 WUI test group list content generator.
83 """
84
85 def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp):
86 assert len(aoEntries) == 0 or isinstance(aoEntries[0], TestGroupDataEx)
87
88 WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
89 sTitle = 'Test Groups', fnDPrint = fnDPrint, oDisp = oDisp);
90 self._asColumnHeaders = [ 'ID', 'Name', 'Description', 'Test Cases', 'Actions' ];
91 self._asColumnAttribs = [ 'align="right"', '', '', '', 'align="center"' ];
92
93
94 def _formatListEntry(self, iEntry):
95 oEntry = self._aoEntries[iEntry];
96 from testmanager.webui.wuiadmin import WuiAdmin;
97
98 #
99 # Test case list.
100 #
101 sHtml = '';
102 if len(oEntry.aoMembers) > 0:
103 for oMember in oEntry.aoMembers:
104 sHtml += '<dl>\n' \
105 ' <dd><strong>%s</strong> (priority: %d) %s %s</dd>\n' \
106 % ( webutils.escapeElem(oMember.oTestCase.sName),
107 oMember.iSchedPriority,
108 WuiTmLink('Details', WuiAdmin.ksScriptName,
109 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestCaseDetails,
110 TestCaseData.ksParam_idGenTestCase: oMember.oTestCase.idGenTestCase, } ).toHtml(),
111 WuiTmLink('Edit', WuiAdmin.ksScriptName,
112 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestCaseEdit,
113 TestCaseData.ksParam_idTestCase: oMember.oTestCase.idTestCase, } ).toHtml()
114 if isDbTimestampInfinity(oMember.oTestCase.tsExpire) else '',
115 );
116
117 sHtml += ' <dt>\n';
118
119 fNoGang = True;
120 for oVar in oMember.oTestCase.aoTestCaseArgs:
121 if oVar.cGangMembers > 1:
122 fNoGang = False
123 break;
124
125 sHtml += ' <table class="tminnertbl" width="100%">\n'
126 if fNoGang:
127 sHtml += ' <tr><th>Timeout</th><th>Arguments</th></tr>\n';
128 else:
129 sHtml += ' <tr><th>Gang Size</th><th>Timeout</th><th style="text-align:left;">Arguments</th></tr>\n';
130
131 cArgsIncluded = 0;
132 for oVar in oMember.oTestCase.aoTestCaseArgs:
133 if oMember.aidTestCaseArgs is None or oVar.idTestCaseArgs in oMember.aidTestCaseArgs:
134 cArgsIncluded += 1;
135 if fNoGang:
136 sHtml += ' <tr>';
137 else:
138 sHtml += ' <tr><td>%s</td>' % (oVar.cGangMembers,);
139 sHtml += '<td>%s</td><td>%s</td></tr>\n' \
140 % ( utils.formatIntervalSeconds(oMember.oTestCase.cSecTimeout if oVar.cSecTimeout is None
141 else oVar.cSecTimeout),
142 webutils.escapeElem(oVar.sArgs), );
143 if cArgsIncluded == 0:
144 sHtml += ' <tr><td colspan="%u">No arguments selected.</td></tr>\n' % ( 2 if fNoGang else 3, );
145 sHtml += ' </table>\n' \
146 ' </dl>\n';
147 oTestCases = WuiRawHtml(sHtml);
148
149 #
150 # Actions.
151 #
152 aoActions = [ WuiTmLink('Details', WuiAdmin.ksScriptName,
153 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestGroupDetails,
154 TestGroupData.ksParam_idTestGroup: oEntry.idTestGroup,
155 WuiAdmin.ksParamEffectiveDate: self._tsEffectiveDate, }) ];
156 if isDbTimestampInfinity(oEntry.tsExpire):
157 aoActions.append(WuiTmLink('Modify', WuiAdmin.ksScriptName,
158 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestGroupEdit,
159 TestGroupData.ksParam_idTestGroup: oEntry.idTestGroup }));
160 aoActions.append(WuiTmLink('Clone', WuiAdmin.ksScriptName,
161 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestGroupClone,
162 TestGroupData.ksParam_idTestGroup: oEntry.idTestGroup,
163 WuiAdmin.ksParamEffectiveDate: self._tsEffectiveDate, }));
164 aoActions.append(WuiTmLink('Remove', WuiAdmin.ksScriptName,
165 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestGroupDoRemove,
166 TestGroupData.ksParam_idTestGroup: oEntry.idTestGroup },
167 sConfirm = 'Do you really want to remove test group #%d?' % (oEntry.idTestGroup,)));
168 else:
169 aoActions.append(WuiTmLink('Clone', WuiAdmin.ksScriptName,
170 { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestGroupClone,
171 TestGroupData.ksParam_idTestGroup: oEntry.idTestGroup,
172 WuiAdmin.ksParamEffectiveDate: self._tsEffectiveDate, }));
173
174
175
176 return [ oEntry.idTestGroup,
177 oEntry.sName,
178 oEntry.sDescription if oEntry.sDescription is not None else '',
179 oTestCases,
180 aoActions ];
181
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