class MyTestCase(unittest.TestCase): def setUp(self): # 初始化环境 print("Initialize the test environment") self.localReadConfig = MyDB() #定义链接数据库方法 self.localReadConfig.connectDB() #连接接数据库 self.ExcelFile = common.get_xls("testcase.xls", "Sheet1") # 读取测试用例 self.localconfigHttp = configHttp.ConfigHttp() # 定义请求方法 self.localconfigsign = configsign.Configsign() # 定义签名方法 self.logger = MyLog.get_log() # 定义日志方法 self.Results = configResults.assertions() # 定义断言方法 # 登陆请求 self.localconfigHttp.set_url(self.ExcelFile[0][2]) self.localconfigHttp.set_json(json.loads(self.ExcelFile[0][3])) self.localconfigHttp.set_headers(json.loads(self.ExcelFile[0][4])) self.login = self.localconfigHttp.post() self.token = self.login.cookies["CCWTOKEN"] self.Results.response_assertions(self.login,self.ExcelFile[0][5],self.ExcelFile[0][6],self.ExcelFile[0][0]) def test_updateUser(self): self.localconfigHttp.set_url(self.ExcelFile[3][2]) self.localconfigHttp.set_json(json.loads(self.ExcelFile[3][3])) self.localconfigHttp.set_headers(json.loads(self.ExcelFile[3][4])) self.localconfigHttp.set_cookie(self.login.cookies) self.localconfigsign.put_sign(self.localconfigHttp.headers,self.localconfigHttp.jsonl,self.token) self.updateUser = self.localconfigHttp.post() self.Results.response_assertions(self.updateUser,self.ExcelFile[3][5],self.ExcelFile[3][6],self.ExcelFile[3][0]) def tearDown(self): # 关闭测试环境 self.localReadConfig.closeDB() print("Close the test environment") sleep(2)
def setUp(self): # 初始化环境 print("Initialize the test environment") self.localReadConfig = MyDB() #定义链接数据库方法 self.localReadConfig.connectDB() #连接接数据库 self.ExcelFile = common.get_xls("testcase.xls", "Sheet1") # 读取测试用例 self.localconfigHttp = configHttp.ConfigHttp() # 定义请求方法 self.localconfigsign = configsign.Configsign() # 定义签名方法 self.logger = MyLog.get_log() # 定义日志方法 self.Results = configResults.assertions() # 定义断言方法 # 登陆请求 self.localconfigHttp.set_url(self.ExcelFile[0][2]) self.localconfigHttp.set_json(json.loads(self.ExcelFile[0][3])) self.localconfigHttp.set_headers(json.loads(self.ExcelFile[0][4])) self.login = self.localconfigHttp.post() self.token = self.login.cookies["CCWTOKEN"] self.Results.response_assertions(self.login,self.ExcelFile[0][5],self.ExcelFile[0][6],self.ExcelFile[0][0])
def checkResult(self): self.info = dict(self.return_json.json()) requestCode = self.info['requestCode'] if requestCode == 0: account = self.account sql = "SELECT account AS account, cardNo AS cardNo,netType AS netType,stakeGroup AS stakeId \ FROM cloud_stakegroup_netmode \ WHERE account = %s" cursor = MyDB().executeSQL(sql, account) val = MyDB().get_all(cursor) if self.assertEqual(val[0][0], str(self.account)): print(val) self.logger.info("Add netMode Successfully!") print "Add netMode Successfully!" else: print "Add netMode failed!" MyDB().closeDB()
def get_value(self, mysql): data = MyDB() global j, i data.connectDB() # 获取当前节点为待金融风控审核的业务单据号 cursor = data.executeSQL(mysql) j = data.get_all(cursor) list = [] for a in j: list.append(a[0]) i = list[0] return i data.closeDB()
from aifc import Error from common.configDB import MyDB myDB = MyDB() #点车库相关 def delUser(cellphone): q = myDB.executeSQL("dccj_20161022", "t_sys_user", "delUser", cellphone) myDB.closeDB() """更改实名认证登记""" def delAuthEntication(cellphone): q = myDB.executeSQL("dccj_20161022", "t_sys_user", "delAuthEntication", cellphone) myDB.closeDB() def getMemberIdBycellphone(cellphone): q = myDB.executeSQL("dccj_20161022", "t_sys_user", "getMemberIdBycellphone", cellphone) if q.rowcount > 0: memberId = q.fetchone()[0] return memberId else: return None myDB.closeDB()
import json from time import sleep from jpype import * import jpype from common.configDB import MyDB import os import readConfig localReadConfig = readConfig.ReadConfig() mydb = MyDB() jvmPath = jpype.get_default_jvm_path() #jarPath1 = "/Users/yongdapay/yongda/utils_jar/utils.jar" jarPath1 = "/Users/yongdapay/yongda/dependencies.jar" dependency = os.path.join(os.path.abspath('.'), "/Users/yongda/yongda/utils_jar") if jpype.isJVMStarted(): pass else: jpype.startJVM(jvmPath, "-Djava.class.path=%s" % jarPath1) securityUtilClass = jpype.JClass("yongda.util.ParamSecurityUtil") spzxMainClass = jpype.JClass("yongda.SpzxMain") # class JSONObejct(object): # def __init__(self,data): # self.__dict__ = json.loads(data) # 获取组装后的接口参数,调用jar包中的JSON class,来生成token