def T_02_getMacByBarCode_A(product): u'''根据单板条码查询MACID-根据单板条码查询MACID''' sb = ServerBusiness() sb.__enter__() try: mac = sb.getProductIdByBarCode( productName="GS11 OBU", suiteName="单板测试", barCode=product.getTestingSuiteBarCode()) except ServerBusiness.NormalException, e: raise AbortTestException(message=u"没有此单板的测试结果")
def procFun(): try: sb = ServerBusiness() sb.__enter__() status = sb.getProductTestStatus(productName=u"GS15 超高频标签", idCode=tid) except: status = None if status is not None: LOCAL_DUPLICATE_TID_SET.add(tid) raise AbortTestException(message=u"被测卡片TID:%s与已测试记录重复,测试失败" % tid) else: uiLog(u"被测卡片TID:%s检测不重复" % tid)
def T_13_setMac_A(product): u"设置MAC地址-设置初始MAC地址" global CURRENT_TESTING_READER, TC ret = CURRENT_TESTING_READER.readMacAddr() nowMac = binascii.hexlify(ret) with ServerBusiness(testflow=True) as sb: shouldMac = sb.getBindingCode(productName=u"KC-RD40-M", idCode=product.getTestingProductIdCode(), bindingCodeName=u"MAC") if shouldMac != "": if shouldMac == nowMac: uiLog(u"已分配过MAC地址") return {u"MAC地址": nowMac} else: uiLog(u"重写MAC地址:" + shouldMac) mac_addr = binascii.unhexlify(shouldMac) CURRENT_TESTING_READER.setMacAddr(mac_addr) ret = CURRENT_TESTING_READER.readMacAddr() TC.assertEqual(ret, mac_addr) product.addBindingCode(u"MAC", shouldMac) return {u"MAC地址": shouldMac} else: mac = serialCode("rd40.mac") uiLog(u"分配新的MAC地址:" + mac) mac_addr = binascii.unhexlify(mac) CURRENT_TESTING_READER.setMacAddr(mac_addr) ret = CURRENT_TESTING_READER.readMacAddr() TC.assertEqual(ret, mac_addr) product.addBindingCode(u"MAC", mac) return {u"MAC地址": mac}
def T_02_MACTest_A(product): u'写入MAC-RD52整机MAC写入测试' if SESSION["AllBarcode"] == "": raise TestItemFailException(failWeight=10, message=u"未进行条码扫描,无法进行mac写入") for i in range(8): pingResult = pingIPOpen(PARAM["defaultNetOneIp"]) if pingResult == "ok": break time.sleep(5) else: raise TestItemFailException(failWeight=10, message=u"连接失败有可能是网口通信问题") time.sleep(3) with ServerBusiness(testflow=True) as sb: getMac = sb.getBindingCode(productName=u"RD52_RSU", idCode=SESSION["AllBarcode"], bindingCodeName=u"MAC") if getMac is not None and getMac != "": # macstrRead = myReadMac() # if macstrRead.upper() != getMac: myWriteMac(getMac) macstrRead2 = myReadMac() if macstrRead2.upper() == getMac: return {u"mac地址": u"mac地址写入成功,%s" % getMac} raise TestItemFailException(failWeight=10, message=u"写入与分配mac不一致,写入mac失败") # else: # return {u"mac地址":u"mac已存在"} else: raise TestItemFailException(failWeight=10, message=u"整机条码未绑定mac,请退回上一工位")
def on_loginButton_clicked(self): '''登录按钮''' if self.serverIp.text().__str__() == 'single': #单机登录,不带服务器的 SESSION["testorRole"] = "SUPER_TESTOR" if self.testor.text( ).__str__() == 'super' else 'TESTOR' SESSION["testor"] = u"单机" SESSION["isMend"] = True self.__initSession() PARAM.dumpParameterToLocalFile() GLOBAL["logUi"].log(u"单机登录,即将测试[%s]产品的[%s]" % (SESSION["product"], SESSION["testsuite"])) self.hide() self.parent().setUiInfoFromSession() else: if not self.__verifyInput(): return with ServerBusiness(self.serverIp.text().__str__()) as sb: user = sb.login( workbay=self.workbay.text().__str__(), username=self.testor.text().__str__(), password=encryPassword(self.password.text().__str__()), product=self.product.currentText().__str__(), testSuite=self.testsuite.currentText().__str__()) SESSION["testorRole"] = user["role"] SESSION["testor"] = user["username"] self.__initSession() PARAM.dumpParameterToLocalFile() GLOBAL["logUi"].log(u"检测员[%s]登录成功,即将测试[%s]产品的[%s]" % (SESSION["testor"], SESSION["product"], SESSION["testsuite"])) self.hide() self.parent().setUiInfoFromSession()
def __checkBoxTestStatus(boxBar): uiLog(u'检查小盒条码%s的包装情况...' % boxBar) with ServerBusiness(testflow=True) as sb: #这里不会混淆,因为小箱条码为18位,大箱为20位 status = sb.getProductTestStatus(productName="GS10包装 ", idCode=boxBar) if status is None: raise AbortTestException(message=u"条码为[%s]的小盒尚未包装,请勿进行大盒包装!" % boxBar)
def T_02_allotCpcId_A(product): u"分配CPCID-分配新的CPCID" # 检查MAC是否已经对应过CPCID with ServerBusiness() as sb: currentCpcIdOnServer = sb.getBindingCode(productName=u"CPC卡片",idCode=product.param["mac"],bindingCodeName=u"CPCID") if currentCpcIdOnServer is not None and currentCpcIdOnServer!="": if currentCpcIdOnServer == product.param["currentCpcId"]: # CPCID完全相同,属于复测,直接判为成功即可 product.param["targetCpcId"] = str(currentCpcIdOnServer) product.param["retest"] = True else: uiLog(u"当前卡片的CPCID:%s,与数据库中记录不符,重新刷写成:%s"%(product.param["currentCpcId"],currentCpcIdOnServer)) product.param["retest"] = False product.param["targetCpcId"] = str(currentCpcIdOnServer) else: uiLog(u"卡片没有刷写过CPCID,分配新的CPCID") # 判断是补卡流程,还是新生产流程。看cpcIdSerialName参数,如果是文件名,说明是补卡;否则是正常ID if "\\" not in PARAM["cpcIdSerialName"]: #从服务端分配,正常生产 targetCpcId = serialCode(PARAM["cpcIdSerialName"]) if targetCpcId > PARAM["endCpcId"]: # 产量已超 retrieveSerialCode(PARAM["cpcIdSerialName"],targetCpcId ) raise AbortTestException(u"CPCID已超过范围,产量已完成") else: #从补卡文件中获取,补卡 targetCpcId = COMP_SERIAL.fetchCpcSerialFromFile() if targetCpcId == "FF"*8: #补卡完成 raise AbortTestException(u"补卡全部完成,本片忽略") uiLog(u"分配新的CPCID:%s"%targetCpcId) product.param["retest"] = False product.param["targetCpcId"] = str(targetCpcId)
def T_01_scanAllCode_A(product): u'扫码条码并写入MAC-扫码单板、整机条码分配MAC并写入' barCode1 = askForSomething(u'扫描条码', u'请扫描RSDB0单板条码', autoCommit=False) __checkManualFinished(barCode1) barCode3 = askForSomething(u'扫描条码', u'请扫描整机条码', autoCommit=False) while not __checkBarCodeAll(barCode3): barCode3 = askForSomething(u"扫描条码", u"整机条码扫描错误,请重新扫描", autoCommit=False) product.setTestingProductIdCode(barCode3) product.setTestingSuiteBarCode(barCode1) with ServerBusiness(testflow=True) as sb: getMac = sb.getBindingCode(productName=u"RD50C_RSU", idCode=barCode3, bindingCodeName=u"MAC") if getMac is not None and getMac != "": mac = getMac else: mac = serialCode(PARAM["macName"]) if int(mac, 16) > int(PARAM["macMax"], 16): raise AbortTestException(message=u"MAC地址超出范围,没有可分配mac") product.addBindingCode(u"MAC", mac) getMac2 = sb.getBindingCode(productName=u"RD50C_RSU", idCode=barCode3, bindingCodeName=u"MAC2") if getMac2 is not None and getMac2 != "": mac2 = getMac2 else: mac2 = serialCode(PARAM["macName"]) if int(mac2, 16) > int(PARAM["macMax"], 16): raise AbortTestException(message=u"MAC地址超出范围,没有可分配mac") product.addBindingCode(u"MAC2", mac2) for i in range(10): pingResult = pingIPOpen(PARAM["defaultNetOneIp"]) if pingResult == "ok": break time.sleep(5) else: raise TestItemFailException(failWeight=10, message=u"连接失败有可能是网口通信问题") macoffset = 0x46 myWriteMac(macoffset, mac) macstrRead = myReadMac(macoffset) macoffset2 = 0x40 myWriteMac(macoffset2, mac2) macstrRead2 = myReadMac(macoffset2) if macstrRead.upper() == mac and macstrRead2.upper() == mac2: return { u"单板条码": barCode1, u"整机条码": barCode3, u"MAC1地址": mac, u"MAC2地址": mac2 } else: TestItemFailException(failWeight=10, message=u"写入与分配mac不一致,写入mac失败")
def __call__(self): global abortReport if idCode in abortReport: abortReport.remove(idCode) uiLog(u"产品:%s测试结果丢弃,测试失败" % idCode) else: with ServerBusiness() as sb: sb.uploadTestReport(report) uiLog(u'产品%s测试结果已保存' % idCode)
def T_04_BatteryVoltage_A(product): u'''电池电路电压测试-返回电池电路电压值,后台根据配置判定''' with ServerBusiness(testflow=True) as sb: pass product.addBindingCode(u"印刷卡号", "88888") sl, sh = SP('gs11.deepStaticCurrent.low', 2), SP('gs11.deepStaticCurrent.high', 18) return {"sl": sl, "sh": sh} time.sleep(1)
def __checkAndPersistEsamId(idCode, esamId): '''检查并立即持久ESAMID的绑定关系''' with ServerBusiness() as sb: if not sb.checkAndPersistUniqueBindingCode(productName="MOCK PRODUCT", idCode=idCode, bindingCodeName=u"ESAMID", code=esamId): raise TestItemFailException(failWeight=10, message=u'ESAMID重复', output={"ESAMID": esamId})
def __checkManualFinished(idCode): '''检查数字单板人工手动工位已完成''' with ServerBusiness(testflow = True) as sb: status = sb.getProductTestStatus(productName="RD52_RSU" ,idCode = idCode) if status is None: raise AbortTestException(message=u"该产品尚未进行RSDB5单板EPLD下载工位的测试,单板测试终止") else: sn1 = downloadEPLD.suiteName if sn1 not in status["suiteStatus"] or status["suiteStatus"][sn1] != 'PASS': raise AbortTestException(message=u"该产品的RSDB5单板EPLD下载工位测试项未进行或未通过,单板测试终止")
def __checkManualFinished(idCode): '''检查数字单板人工手动工位已完成''' with ServerBusiness(testflow = True) as sb: status = sb.getProductTestStatus(productName="RD50C_RSU" ,idCode = idCode) if status is None: raise AbortTestException(message=u"该产品尚未进行人工手动测试1,自动化测试终止") else: sn1 = try_test1.suiteName if sn1 not in status["suiteStatus"] or status["suiteStatus"][sn1] != 'PASS': raise AbortTestException(message=u"该产品的单板测试项未进行或未通过,整机测试终止")
def __checkAutoFinished(idCode): '''检查RSDB5单板功能测试工位已完成''' with ServerBusiness(testflow = True) as sb: status = sb.getProductTestStatus(productName="RD52_RSU" ,idCode = idCode) if status is None: raise AbortTestException(message=u"RSDB5尚未进行单板功能测试,整机测试终止") else: sn = RSDB5AutoTest.suiteName if sn not in status["suiteStatus"] or status["suiteStatus"][sn] != 'PASS': raise AbortTestException(message=u"RSDB5单板功能测试项未进行或未通过,整机测试终止")
def __uploadTestReport(self, toUploadReport): # 执行上报 with ServerBusiness() as sb: sb.actionAndCheckSuccess( "%s?%s" % (toUploadReport["funName"], toUploadReport["requestUUID"]), str(toUploadReport["payload"]), encodeToUrl=False) uiLog(u'测试报告%s上传成功' % (toUploadReport["requestUUID"].split("-")[1]))
def __checkBoardFinished(idCode): '''检查单板(数字、射频)工位已完成''' with ServerBusiness(testflow=True) as sb: status = sb.getProductTestStatus(productName="GS11 OBU", idCode=idCode) if status is None: raise AbortTestException(message=u"该产品尚未进行单板测试,整机测试终止") else: sn1 = board.suiteName if sn1 not in status[ "suiteStatus"] or status["suiteStatus"][sn1] != 'PASS': raise AbortTestException(message=u"该产品的单板测试项未进行或未通过,整机测试终止")
def __checkRSRB4Finished(idCode): '''检查射频单板功能测试已完成''' with ServerBusiness(testflow=True) as sb: status = sb.getProductTestStatus(productName="RD52_RSU", idCode=idCode) if status is None: raise AbortTestException(message=u"RSRB4射频板尚未进行单板测试,整机测试终止") else: sn = RSRB4SendRecvTest.suiteName if sn not in status[ "suiteStatus"] or status["suiteStatus"][sn] != 'PASS': raise AbortTestException( message=u"RSRB4的单板电源&单板功能测试测试项未进行或未通过,整机测试终止")
def __checkManualFinished(idCode): '''检查数字单板人工手动工位已完成''' with ServerBusiness(testflow=True) as sb: status1 = sb.getProductTestStatus(productName="RD50C_RSU", idCode=idCode) if status1 is None: raise AbortTestException(message=u"尚未进行整机测试,老化测试终止") else: sn = lightBoard_test.suiteName if sn not in status1[ "suiteStatus"] or status1["suiteStatus"][sn] != 'PASS': raise AbortTestException(message=u"整机测试未通过,老化测试终止")
def T_03_unbindAllCode_A(product): u'''解除单板绑定属性-解除单板的绑定属性''' with ServerBusiness() as sb: #ESAMID与GS10共用,因为需要两类产品共同比对 sb.unbindCode(productName="GS10 OBU", idCode=product.getTestingProductIdCode(), bindingCodeName="ESAMID") sb.unbindCode(productName="GS11 OBU", idCode=product.getTestingProductIdCode(), bindingCodeName=u"合同序列号") sb.unbindCode(productName="GS11 OBU", idCode=product.getTestingProductIdCode(), bindingCodeName=u"镭雕条码")
def __checkTestFinished(idCode): '''检查产品测试已完成''' with ServerBusiness(testflow=True) as sb: status = sb.getProductTestStatus(productName="GS11 OBU", idCode=idCode) if status is None: raise AbortTestException(message=u"该产品尚未进行单板测试,整机测试终止") else: sn = overall.suiteName if sn not in status["suiteStatus"] or status["suiteStatus"][ sn] == 'UNTESTED': raise AbortTestException(message="该产品测试[%s]项尚未完成,绑定终止" % sn) if status["suiteStatus"][sn] != 'PASS': raise AbortTestException(message="该产品测试项[%s]不通过,绑定终止" % sn)
def __checkAndPersistEsamId(idCode, esamId): '''检查并立即持久ESAMID的绑定关系''' if idCode is None: return with ServerBusiness(testflow=True) as sb: if not sb.checkAndPersistUniqueBindingCode(productName="GS10 OBU", idCode=idCode, bindingCodeName=u"ESAMID", code=esamId): raise TestItemFailException(failWeight=10, message=u'ESAMID重复', output={"ESAMID": esamId}) uiLog(u"ESAMID重复检查通过")
def __checkManualFinished(idCode): '''检查RSDB0单板电源&BOOT下载工位已完成''' with ServerBusiness(testflow=True) as sb: status = sb.getProductTestStatus(productName="RD50C_RSU", idCode=idCode) if status is None: raise AbortTestException(message=u"RSDB0尚未进行单板测试,RSDB0单板功能测试终止") else: sn1 = manual_test.suiteName if sn1 not in status[ "suiteStatus"] or status["suiteStatus"][sn1] != 'PASS': raise AbortTestException( message=u"RSDB0单板电源&BOOT下载测试项未进行或未通过,RSDB0单板功能测试终止")
def performTestThread(): global totalProductCount with ServerBusiness() as sb: while True: startTime = time.time() idCode = serialCode("mac") sb.uploadTestReport(generateMockReport(idCode, 1)) time.sleep(3.5) sb.uploadTestReport(generateMockReport(idCode, 2)) time.sleep(3.5) sb.uploadTestReport(generateMockReport(idCode, 3)) totalProductCount = totalProductCount + 1 time.sleep(3.5) endTime = time.time() print u'完成一个,平均交互耗时:%f秒' % ((endTime - startTime - 10.5) / 3)
def T_01_readMacAndCheckBoard_M(product): u"MAC检查-读取OBU的MAC并检查单板数字是否测试通过" r = __askForPlateDeviceCom(product.productSlot).sendAndGet( "D-ReadFlashPara 0x02 0x00 0x10").strip() if not r.startswith("D-ReadFlashOK"): raise AbortTestException(message=u"读取OBU的MAC地址失败") obuFlash = util.cmdFormatToHexStr(r[14:]) obuid = obuFlash[8:16] uiLog(u"读取到OBUID:" + obuid) return {"obumac": obuid} if obuid == "ffffffff": raise AbortTestException(message=u"单板未写入MAC,请退回单板数字测试工位") with ServerBusiness(testflow=True) as sb: status = sb.getProductTestStatus(productName="GS11 OBU") if status is None: raise AbortTestException(message=u"单板未进行数字测试,请退回单板数字测试工位")
def T_02_verifyHistoryPackaging_A(product): u'''判断小盒历史包装情况-自动检查该小盒的历史包装情况,如果已包装过,则本次进行补充包装''' idCode = product.getTestingProductIdCode() with ServerBusiness() as sb: unpackagedStr = sb.getBindingCode(productName=u"GS15卡片包装",idCode=idCode,bindingCodeName=u"未包装个体") if unpackagedStr == "": uiLog(u"%s盒为新包装"%idCode) else: if manulCheck(u"GS15包装", u"此盒[%s]已包装但有缺失,是否进行补充包装?"%idCode,check="confirm"): uiLog(u"%s盒已包装过,进行补充包装"%idCode) unpackaged = unpackagedStr.split(",") for item in product.param["itemBarCodeList_should"]: if item not in unpackaged: product.param["itemBarCodeList_actual"].append(item) else: uiLog(u"%s盒重新进行包装"%idCode)
def __checkTestFinished(idCode): # 检查产品测试已完成 with ServerBusiness(testflow = True) as sb: status = sb.getProductTestStatus(productName=u"CPC卡片" ,idCode = idCode) if status is None: raise AbortTestException(message=u"该产品尚未进行交易测试") else: sn1 = u"CPC集成出入口及路径标识测试" sn2 = u"整机MAC更新" if sn1 not in status["suiteStatus"] and sn2 not in status["suiteStatus"]: raise AbortTestException(message=u"该产品测试未进行交易测试,请退回前续工序") if sn2 in status["suiteStatus"]: if status["suiteStatus"][sn2] != 'PASS': raise AbortTestException(message=u"该产品交易测试未通过,请退回前续工序") elif sn1 in status["suiteStatus"] and status["suiteStatus"][sn1] != 'PASS': raise AbortTestException(message=u"该产品交易测试未通过,请退回前续工序")
def __checkObuTestStatus(laserCode): uiLog(u'正在检查镭雕码为【%s】的产品测试情况...' % laserCode) with ServerBusiness(testflow=True) as sb: idCode = sb.getProductIdByBindingCode(productName="GS11 OBU", codeName=u"镭雕条码", code=laserCode) status = sb.getProductTestStatus(productName="GS11 OBU", idCode=idCode) if status is None: raise AbortTestException(message=u"镭雕条码为【%s】的产品尚未测试,请勿包装!" % laserCode) for sn in (u"单板测试", u"整机测试", u"交易绑定工位测试项"): if sn not in status["suiteStatus"] or status["suiteStatus"][ sn] == 'UNTESTED': raise AbortTestException( message="镭雕条码为【%s】的产品的[%s]测试项尚未进行,请勿包装!" % (laserCode, sn)) if status["suiteStatus"][sn] != 'PASS': raise AbortTestException( message="镭雕条码为【%s】的产品的[%s]测试项未通过,请勿包装!" % (laserCode, sn))
def on_submitButton_clicked(self): if isEmptyString(self.oldPassword.text()) or \ isEmptyString(self.newPassword.text()) or \ isEmptyString(self.reNewPassword.text()): QMessageBox.warning(None, u"修改密码", u"请正确填写参数!", QMessageBox.Ok) return if self.newPassword.text().__str__() != self.reNewPassword.text( ).__str__(): QMessageBox.warning(None, u"修改密码", u"两次输入的新密码不相同!", QMessageBox.Ok) return with ServerBusiness() as sb: sb.modifyPassword( username=SESSION["testor"], oldpassword=encryPassword(self.oldPassword.text().__str__()), newpassword=encryPassword(self.newPassword.text().__str__())) QMessageBox.information(None, u"修改密码", u"密码修改完成!") self.hide() pass
def __checkTestResult(barCode): '''检查该条码的卡片是否经过了测试''' sb = ServerBusiness() sb.__enter__() try: idCode = sb.getProductIdByBindingCode(productName=u"GS15 超高频标签", codeName=u"条码", code=barCode) if idCode == None: return False status = sb.getProductTestStatus(productName=u"GS15 超高频标签" , idCode=idCode) if status is None: return False if OVERALL_SUITE_NAME not in status["suiteStatus"] or status["suiteStatus"][OVERALL_SUITE_NAME] != 'PASS': return False return True except: return False
def T_01_scanCode_A(product): u'扫码条码-扫描条码' barCode1 = askForSomething(u'扫描条码', u'请扫描RSDB5数字单板条码', autoCommit=False) __checkRSDB5Finished(barCode1) barCode2 = askForSomething(u'扫描条码', u'请扫描RSRB4射频单板条码', autoCommit=False) __checkRSRB4Finished(barCode2) barCode3 = askForSomething(u'扫描条码', u'请扫描整机条码', autoCommit=False) while not __checkBarCode(barCode3): barCode3 = askForSomething(u"扫描条码", u"整机条码扫描错误,请重新扫描", autoCommit=False) product.setTestingProductIdCode(barCode3) product.setTestingSuiteBarCode(barCode1) with ServerBusiness(testflow=True) as sb: getMac = sb.getBindingCode(productName=u"RD52_RSU", idCode=barCode3, bindingCodeName=u"MAC") if getMac is not None and getMac != "": mac = getMac else: mac = serialCode(PARAM["macName"]) if int(mac, 16) > int(PARAM["macMax"], 16): raise AbortTestException(message=u"MAC地址超出范围,没有可分配mac") product.addBindingCode(u"MAC", mac) # mac = serialCode(PARAM["macName"]) # if int(mac, 16) > int(PARAM["macMax"], 16): # raise AbortTestException(message=u"MAC地址超出范围,没有可分配mac") # product.addBindingCode(u"MAC", mac) return { u"RSDB5数字单板条码": barCode1, u"RSRB4射频单板条码": barCode2, u'整机条码': barCode3, u"MAC地址": mac }