def initFromDbRowEx(self, aoRow): """ Reinitialize from a :WRONG QUERY: SELECT TestCases.idTestCase, TestGroupMembers.tsEffective, TestGroupMembers.tsExpire, TestGroupMembers.uidAuthor, TestCases.idGenTestCase, TestCases.sName, TestCases.sDescription, TestCases.fEnabled, TestCases.cSecTimeout, TestCases.sBaseCmd, TestCases.sValidationKitZips, TestGroupMembers.idTestGroup, TestGroupMembers.aidTestCaseArgs FROM TestCases, TestGroupMembers WHERE TestCases.idTestCase = TestGroupMembers.idTestCase ..row. Represents complete test group member (test case) info. Returns object of type TestGroupMemberData2. Raises exception if no row. """ TestCaseData.initFromDbRow(self, aoRow); self.idTestGroup = aoRow[-2] self.aidTestCaseArgs = aoRow[-1] return self;
def getTestCasesForGroup(self, idSchedGroup, cMax = None): """ Gets the enabled testcases w/ testgroup+priority for the given scheduling group. Returns an array TestCaseData instance (group id, testcase priority and testcase ids) with an extra iSchedPriority member. May raise exception on DB error or if the result exceeds cMax. """ self._oDb.execute('SELECT TestGroupMembers.idTestGroup, TestGroupMembers.iSchedPriority, TestCases.*\n' 'FROM SchedGroupMembers, TestGroups, TestGroupMembers, TestCases\n' 'WHERE SchedGroupMembers.idSchedGroup = %s\n' ' AND SchedGroupMembers.tsExpire = \'infinity\'::TIMESTAMP\n' ' AND TestGroups.idTestGroup = SchedGroupMembers.idTestGroup\n' ' AND TestGroups.tsExpire = \'infinity\'::TIMESTAMP\n' ' AND TestGroupMembers.idTestGroup = TestGroups.idTestGroup\n' ' AND TestGroupMembers.tsExpire = \'infinity\'::TIMESTAMP\n' ' AND TestCases.idTestCase = TestGroupMembers.idTestCase\n' ' AND TestCases.tsExpire = \'infinity\'::TIMESTAMP\n' ' AND TestCases.fEnabled = TRUE\n' 'ORDER BY TestGroupMembers.idTestGroup, TestGroupMembers.iSchedPriority, TestCases.idTestCase\n' , (idSchedGroup,)); if cMax is not None and self._oDb.getRowCount() > cMax: raise TMExceptionBase('Too many testcases for scheduling group %s: %s, max %s' % (idSchedGroup, cMax, self._oDb.getRowCount(),)); aoRet = []; for aoRow in self._oDb.fetchAll(): oTestCase = TestCaseData().initFromDbRow(aoRow[2:]); oTestCase.idTestGroup = aoRow[0]; oTestCase.iSchedPriority = aoRow[1]; aoRet.append(oTestCase); return aoRet;
def initFromDbRowEx(self, aoRow): """ Reinitialize from a :WRONG QUERY: SELECT TestCases.idTestCase, TestGroupMembers.tsEffective, TestGroupMembers.tsExpire, TestGroupMembers.uidAuthor, TestCases.idGenTestCase, TestCases.sName, TestCases.sDescription, TestCases.fEnabled, TestCases.cSecTimeout, TestCases.sBaseCmd, TestCases.sValidationKitZips, TestGroupMembers.idTestGroup, TestGroupMembers.aidTestCaseArgs FROM TestCases, TestGroupMembers WHERE TestCases.idTestCase = TestGroupMembers.idTestCase ..row. Represents complete test group member (test case) info. Returns object of type TestGroupMemberData2. Raises exception if no row. """ TestCaseData.initFromDbRow(self, aoRow) self.idTestGroup = aoRow[-2] self.aidTestCaseArgs = aoRow[-1] return self
def matchesBuildProps(self, oBuildDataEx): """ Checks if the all of the build related test requirements matches the given build. Returns True or False according to the expression, None on exception or non-boolean expression result. """ return TestCaseData.matchesBuildPropsEx(oBuildDataEx, self.oTestCase.sBuildReqExpr) \ and TestCaseData.matchesBuildPropsEx(oBuildDataEx, self.sBuildReqExpr);
def matchesTestBoxProps(self, oTestBoxData): """ Checks if the all of the testbox related test requirements matches the given testbox. Returns True or False according to the expression, None on exception or non-boolean expression result. """ return TestCaseData.matchesTestBoxPropsEx(oTestBoxData, self.oTestCase.sTestBoxReqExpr) \ and TestCaseData.matchesTestBoxPropsEx(oTestBoxData, self.sTestBoxReqExpr)
def matchesBuildProps(self, oBuildDataEx): """ Checks if the all of the build related test requirements matches the given build. Returns True or False according to the expression, None on exception or non-boolean expression result. """ return TestCaseData.matchesBuildPropsEx(oBuildDataEx, self.oTestCase.sBuildReqExpr) \ and TestCaseData.matchesBuildPropsEx(oBuildDataEx, self.sBuildReqExpr)
def matchesTestBoxProps(self, oTestBoxData): """ Checks if the all of the testbox related test requirements matches the given testbox. Returns True or False according to the expression, None on exception or non-boolean expression result. """ return TestCaseData.matchesTestBoxPropsEx(oTestBoxData, self.oTestCase.sTestBoxReqExpr) \ and TestCaseData.matchesTestBoxPropsEx(oTestBoxData, self.sTestBoxReqExpr);
def _validateAndConvertAttribute(self, sAttr, sParam, oValue, aoNilValues, fAllowNull, oDb): if sAttr == 'cSecTimeout' and oValue not in aoNilValues: # Allow human readable interval formats. return utils.parseIntervalSeconds(oValue); (oValue, sError) = ModelDataBase._validateAndConvertAttribute(self, sAttr, sParam, oValue, aoNilValues, fAllowNull, oDb); if sError is None: if sAttr == 'sTestBoxReqExpr': sError = TestCaseData.validateTestBoxReqExpr(oValue); elif sAttr == 'sBuildReqExpr': sError = TestCaseData.validateBuildReqExpr(oValue); return (oValue, sError);
def getTestCase(self, idTestCase): """ Gets the corresponding TestCaseData object. """ oRet = self._adCache[self.ksObjType_TestCase_idTestCase].get(idTestCase); if oRet is None: # Load cache entry. from testmanager.core.testcase import TestCaseData; oRet = TestCaseData(); try: oRet.initFromDbWithId(self._oDb, idTestCase, self.tsNow, self.sPeriodBack); except: self._handleDbException(); raise; else: self._adCache[self.ksObjType_TestCase_idGenTestCase][oRet.idGenTestCase] = oRet; self._adCache[self.ksObjType_TestCase_idTestCase][idTestCase] = oRet; return oRet;
def getTestCase(self, idTestCase): """ Gets the corresponding TestCaseData object. """ oRet = self._adCache[self.ksObjType_TestCase_idTestCase].get(idTestCase); if oRet is None: # Load cache entry. from testmanager.core.testcase import TestCaseData; oRet = TestCaseData(); try: oRet.initFromDbWithId(self._oDb, idTestCase, self.tsNow, self.sPeriodBack); except: self._handleDbException(); else: self._adCache[self.ksObjType_TestCase_idGenTestCase][oRet.idGenTestCase] = oRet; self._adCache[self.ksObjType_TestCase_idTestCase][idTestCase] = oRet; return oRet;
def initFromDbWithGenIdEx(self, oDb, idGenTestCaseArgs, tsConfigEff=None, tsRsrcEff=None): """ Initialize from the database, given the ID of a row. """ oDb.execute( 'SELECT *, CURRENT_TIMESTAMP FROM TestCaseArgs WHERE idGenTestCaseArgs = %s', (idGenTestCaseArgs, )) aoRow = oDb.fetchOne() TestCaseArgsData.initFromDbRow(self, aoRow) tsNow = aoRow[11] if tsConfigEff is None: tsConfigEff = tsNow if tsRsrcEff is None: tsRsrcEff = tsNow self.oTestCase = TestCaseData().initFromDbWithId( oDb, self.idTestCase, tsConfigEff) self.aoTestCasePreReqs = TestCaseDependencyLogic(oDb).getTestCaseDeps( self.idTestCase, tsConfigEff) self.aoGlobalRsrc = TestCaseGlobalRsrcDepLogic(oDb).getTestCaseDeps( self.idTestCase, tsRsrcEff) return self
def initFromDbRowEx(self, aoRow): """ Reinitialize from this query: SELECT TestCases.*, TestGroupMembers.idTestGroup, TestGroupMembers.aidTestCaseArgs FROM TestCases, TestGroupMembers WHERE TestCases.idTestCase = TestGroupMembers.idTestCase Represents complete test group member (test case) info. Returns object of type TestGroupMemberData2. Raises exception if no row. """ TestCaseData.initFromDbRow(self, aoRow) self.idTestGroup = aoRow[-2] self.aidTestCaseArgs = aoRow[-1] return self
def initFromDbRowEx(self, aoRow): """ Reinitialize from this query: SELECT TestCases.*, TestGroupMembers.idTestGroup, TestGroupMembers.aidTestCaseArgs FROM TestCases, TestGroupMembers WHERE TestCases.idTestCase = TestGroupMembers.idTestCase Represents complete test group member (test case) info. Returns object of type TestGroupMemberData2. Raises exception if no row. """ TestCaseData.initFromDbRow(self, aoRow); self.idTestGroup = aoRow[-2] self.aidTestCaseArgs = aoRow[-1] return self;
def initFromDbRowEx(self, aoRow, oDb, tsConfigEff = None, tsRsrcEff = None): """ Extended version of initFromDbRow that fills in the rest from the database. """ TestCaseArgsData.initFromDbRow(self, aoRow); if tsConfigEff is None: tsConfigEff = oDb.getCurrentTimestamp(); if tsRsrcEff is None: tsRsrcEff = oDb.getCurrentTimestamp(); self.oTestCase = TestCaseData().initFromDbWithId(oDb, self.idTestCase, tsConfigEff); self.aoTestCasePreReqs = TestCaseDependencyLogic(oDb).getTestCaseDeps(self.idTestCase, tsConfigEff); self.aoGlobalRsrc = TestCaseGlobalRsrcDepLogic(oDb).getTestCaseDeps(self.idTestCase, tsRsrcEff); return self;
def __init__(self): """Extend parent class""" TestCaseData.__init__(self) self.idTestGroup = None self.aidTestCaseArgs = []