def formatTestCase(self, testcases): cases = [] for t in testcases: cases.append(cprop.getVal("testcase", 'caseRow').format(**t)) return open(cprop.getVal("testcase", 'caseReportTemplate')).read().replace( "{testcases}", "".join(cases))
def __setup__(self): self._addEnum("planStatus", cprop.getVal("plan", "planStatus"), True) self._addEnum("planCaseStatus", cprop.getVal("plan", "planCaseStatus"), True) self._addEnum("planPriority", cprop.getVal("plan", "planPriority"), False) self._addEnum("planType", cprop.getVal("plan", "planType"), False) self._addEnum("deployPhase", "未提测 测试 预发布 正式发布 完成", True) self._addEnum("deployStatus", "未部署 部署中 部署成功 部署失败 冻结 完成", True)
def __init__(self): ProxyHttpHandle.__init__(self) from cserver import cprop self.__setFromIpLogPath__( cprop.getVal("proxyLog", "logFolder", "."), cprop.getVal("proxyLog", "fromIps", "."), cprop.getVal("proxyLog", "pathStartswith", "."), cprop.getVal("proxyLog", "pathEndswith", "."))
def sendPlandailyEmail(self, planid, day, sender, receiver, ccReceiver=''): subject, htmlBody = self.getPlandailyEmail(planid, day) smtpSender = cprop.getVal("email", "smtpSender") smtpAddr = cprop.getVal("email", "smtpAddr") smtpLogin = cprop.getVal("email", "smtpLogin") mimeMail = self.emailRp.makeEmail(sender, receiver, ccReceiver, subject, htmlBody) self.dbapi.saveCtestplanStatus(planid, mailto=receiver, mailfrom=sender, mailcc=ccReceiver) return self.emailRp.sendEmail(smtpAddr, smtpLogin, smtpSender, receiver, ccReceiver, mimeMail)
def getCtestplancasereport(self, planid): planCaseRow = cprop.getVal('plan', 'planCaseRow') planCaseStatus = cprop.getVal('plan', 'planCaseStatus').split() caseinfo = [] for case in self.dbapi.getPlancase(planid): case['result'] = planCaseStatus[case['status']] case['remark'] = '' if case['remark'] is None else case['remark'] caseinfo.append(planCaseRow.format(**case)) return cprop.getVal('plan', 'planCaseTable').format(body="".join(caseinfo))
def sendPlanSummaryEmail(self, planid, summary, issues, sender, receiver, ccReceiver, isSetFinish): subject, emailbody = self.getPlanSummaryReport(planid, summary, issues, isSetFinish) open("testreport.html", "wb").write(emailbody) smtpSender = cprop.getVal("email", "smtpSender") smtpAddr = cprop.getVal("email", "smtpAddr") smtpLogin = cprop.getVal("email", "smtpLogin") mimeMail = self.emailRp.makeEmail(sender, receiver, ccReceiver, subject, emailbody) self.dbapi.saveCtestplanStatus(planid, mailto=receiver, mailfrom=sender, mailcc=ccReceiver) return self.emailRp.sendEmail(smtpAddr, smtpLogin, smtpSender, receiver, ccReceiver, mimeMail)
def sendPlanReport(self, sender, receiver, ccReceiver, subject, ptype, inStatus=None, outStatus=None, fnid=None, nid1=None, nid2=None, name='all', tags=None, starttime1=None, starttime2=None): htmlBody = self.getPlanReport(ptype, inStatus, outStatus, fnid, nid1, nid2, name, tags, starttime1, starttime2) smtpSender = cprop.getVal("email", "smtpSender") smtpAddr = cprop.getVal("email", "smtpAddr") smtpLogin = cprop.getVal("email", "smtpLogin") mimeMail = self.emailRp.makeEmail(sender, receiver, ccReceiver, subject, htmlBody) return self.emailRp.sendEmail(smtpAddr, smtpLogin, smtpSender, receiver, ccReceiver, mimeMail)
def __init__(self): sqlConfig = { 'host': cprop.getVal("db", "host"), 'port': cprop.getInt("db", "port"), 'user': cprop.getVal("db", "user"), 'passwd': cprop.getVal("db", "passwd"), 'db': cprop.getVal("db", "db"), 'charset': 'utf8' } self.sqlConn = SqlConnFactory(MysqldbConn, sqlConfig)
def __init__(self): ProxyHttpHandle.__init__(self) from cserver import cprop self.__setFromIpLogPath__( cprop.getVal("proxyLog", "logFolder", "."), cprop.getVal("proxyLog", "fromIps", "."), cprop.getVal("proxyLog", "pathStartswith", "."), cprop.getVal("proxyLog", "pathEndswith", "."), cprop.getBool("proxyLog", "logNameHasOrigin", 'true'), cprop.getInt("proxyLog", "logRespSize", 1024), cprop.getVal("proxyLog", "logAllUrl", ''))
def __init__(self): dataPath = cprop.getVal("ctool", "dataPath", "./webs/data") self.datas = FileDataBase(dataPath, keyDefines={ 'a': 'json', 't': 'equal' }) self.servers = FileDataBase(dataPath, keyDefines={'a': 'equal'})
def __init__(self, taskcls=None): self.serverhost = cprop.getVal("task", "serverhost") self.serverpath = "TestPlanApi/proxyApi" self.serverauth = cprop.getVal("task", "serverauth") self.nodename = cprop.getVal("task", "nodename") self.nodehost = cprop.getVal("task", "nodehost") self._taskmgr = TaskMananger(True, groupInterval=60, poolSize=1) if taskcls is None: taskcls = SyncFunctionTaskHandle self.task = taskcls(self._syncTasks, self._callServer) try: self.task.rhandler = self.run slog.info("Using function run") except:pass self._taskmgr.addTaskGroup("online", self.task , 2, 2) self._taskmgr.saveTask('pullTask', span=300, fun=self._pullTasks) self._taskmgr.operateTask("pullTask")
def saveTestConfig(self, cname, calias=None, status=None, subject=None, ckey=None, stype=None, ccontent=None, fnid=None, nid1=None, nid2=None, configid=None, __session__=None): owner = __session__['name'] if stype == '3' and ccontent.strip() != '': fileFolder = cprop.getVal('cconfig', 'fileFolder') with open(fileFolder + cname, 'wb') as f: f.write(ccontent) return self.dbapi.saveTestConfig(cname, calias, status, subject, ckey, stype, ccontent, owner, fnid, nid1, nid2, configid)
def getCtestplanById(self, planid): if Sql.isEmpty(planid): return plans = self.dbapi.getCtestplan(planid=planid) if len(plans) > 0: plan = plans[0] planStatus = cprop.getVal('plan', 'planStatus').split() plan['planStatus'] = planStatus[plan['status']] if plan['version'] is None:plan['version'] = "" plan['pstarttime'] = str(plan['pstarttime']).split()[0] plan['pendtime'] = str(plan['pendtime']).split()[0] plan['starttime'] = str(plan['starttime']).split()[0] plan['endtime'] = str(plan['endtime']).split()[0] plan['reportTarget'] = cprop.getVal('plan', 'reportTarget').format(**plan) plan['reportSummary'] = cprop.getVal('plan', 'reportSummary').format(**plan) caseprogress = self.calcPlancaseprogress(planid) plan['reportSummary'] = plan['reportSummary'].format(caseprogress=caseprogress) return plans
def getPlanSummaryReport(self, planid, summary, issues, isSetFinish=False): isSetFinish = str(isSetFinish).lower() == 'true' psummary = self.getPlanSummary(planid) if psummary is None: day = self.getDay() else: day = psummary['day'] if isSetFinish: self.savePlandaily(planid, day, status=self.planStatusFinished, progress=100, caseprogress=None, costtime=None, costman=None, starttime=None, endtime=None, summary=summary, issues=issues) cplan = self.getCtestplanById(planid)[0] casereport = self.getCtestplancasereport(planid) subject = cprop.getVal("plan", "reportSubject").format(**cplan) emailbody = self.emailRp.formatPlanreport(cplan['reportTarget'], cplan['reportSummary'], summary, issues, casereport) return subject, emailbody
def __init__(self): self.emailDailySubject = cprop.getVal('plan', 'emailDailySubject') self.emailDailySp = cprop.getVal('plan', 'emailDailySp') self.emailDailyRow = cprop.getVal('plan', 'emailDailyRow') self.emailDailyBody = cprop.getVal('plan', 'emailDailyBody') self.planLink = cprop.getVal('plan', 'planLink') self.emailDailyTitle = cprop.getVal('plan', 'emailDailyTitle') self.riskStatusDefine = cprop.getVal('plan', 'planStatus').split() self.emailPlanBodyTemplate = cprop.getVal('plan', 'emailPlanBodyTemplate') emailPlanRowFormat = 'textarea' self.emailPlanRowFormat = ObjOperation.tryGetVal( { 'textarea': "<textarea>%s</textarea>", 'pre': "<pre>%s</pre>" }, emailPlanRowFormat, '%s') self.emailPlanRow = cprop.getVal('plan', 'emailPlanRow') self.emailPlanRowTitle = cprop.getVal('plan', 'emailPlanRowTitle') self.reportBodyTemplate = cprop.getVal('plan', 'reportBodyTemplate')
def __init__(self): self.dbapi = object() # imported from CTestPlanAPi self.sysadmin = cprop.getVal("plan", "sysadmin") self.tjson = TimmerJson() LocalMemSessionHandler.__init__(self)
def getTestConfig(self, subject=None, stype=None, cname=None, ckey=None, fnid=None, nid1=None, nid2=None, status=None, configid=None): return {'fileLink':cprop.getVal('cconfig', 'fileLink'), 'data':self.dbapi.getTestConfig(subject, stype, cname, ckey, fnid, nid1, nid2, status=status, configid=configid)}