Пример #1
0
 def testBankValid(self):
     """绑定银行卡"""
     self.cls = common.getXls("testCase.xlsx", "test1")
     self.log = log.get_log()
     self.readConfig = ReadConfig.ReadConfig()
     self.logger = self.log.getLogger()
     self.Http = configHttp.ConfigHttp()
     self.HttpUrl = self.Http.setUrl(self.cls.get(9).get("url"))
     self.logger.info(self.HttpUrl)
     TempParams = json.loads(self.cls.get(9).get("params"))
     self.readConfig.setReslConfig("channelId", common.getChannelId())
     #TempParams["channelId"] = self.readConfig.getReslConfig("channelId")
     TempParams["mobile"] = self.readConfig.getReslConfig("mobile")
     TempParams["idCard"] = self.readConfig.getReslConfig("idnum")
     TempParams["name"] = self.readConfig.getReslConfig("realname")
     self.params = json.dumps(TempParams)
     self.logger.info(self.params)
     self.Http.setParams(self.params)
     self.Http.setHeaders("jwt", self.readConfig.getReslConfig("jwt"))
     self.r = self.Http.post()
     self.r.status_code
     self.r.encoding = 'utf-8'
     self.logger.info("result-----------", self.r.json().get("errorCode"))
     assert self.r.status_code == 200, "请求失败"
     assert self.r.json().get("errorCode") == "0000000", "响应失败"
Пример #2
0
    def __init__(self):
        self.caseListPath = os.path.join(readConfig.rootDir, "caseList")
        self.caseList = []

        self.log = log.get_log()
        self.logger = self.log.getLogger()
        self.reportPath = self.log.getReprotPath()
        self.email = MyEmail.getEmail()
        self.onOff = self.email.onOff
Пример #3
0
 def __init__(self):
     global log, logger, reportPath
     log = Log.get_log()
     logger = log.get_logger()
     reportPath = log.get_report_path()
     self.caseListFile = os.path.join(proDir, "testFile", "caseList.txt")
     # 测试用例文件夹
     self.caseFile = os.path.join(readConfig.proDir, "testCase")
     print(self.caseFile)
     # 测试用例名称
     self.caseList = []
Пример #4
0
 def __init__(self):
     global host, port, timeOut
     host = localReadConfig.getHttpConfig("host")
     port = localReadConfig.getHttpConfig("port")
     #timeout:设置接口连接的最大时间(超过该时间会抛出超时错误)
     timeOut = localReadConfig.getHttpConfig("timeOut")
     self.log = log.get_log()
     self.logger = self.log.getLogger()
     #headers:定制请求头(headers),例如:content-type = application/x-www-form-urlencoded
     self.headers = eval(localReadConfig.getHttpConfig("header"))
     #params:用于传递测试接口所要用的参数,这里我们用python中的字典形式(key:value)进行参数的传递。
     self.params = {}
     self.data = {}
     #url:显而易见,就是接口的地址url啦
     self.url = None
     self.files = {}
Пример #5
0
 def testImg1(self):
     """获取图形验证码"""
     self.cls = common.getXls("testCase.xlsx", "test1")
     self.log = log.get_log()
     self.logger = self.log.getLogger()
     self.Http = configHttp.ConfigHttp()
     self.HttpUrl = self.Http.setUrl(self.cls.get(0).get("url"))
     self.logger.info(self.HttpUrl)
     self.Http.setParams(self.cls.get(0).get("params"))
     self.r = self.Http.get()
     self.r.status_code
     self.r.encoding = 'utf-8'
     self.r.text
     self.logger.info(self.r.text)
     self.logger.info(self.r.status_code)
     self.imgCodeId = self.r.json().get("data").get("imgCodeId")
     self.confige.setReslConfig("imgCodeId", self.imgCodeId)
Пример #6
0
 def testImg(self):
     """获取图形验证码"""
     self.cls = common.getXls("testCase.xlsx", "test1")
     self.log = log.get_log()
     self.logger = self.log.getLogger()
     self.Http = configHttp.ConfigHttp()
     self.HttpUrl = self.Http.setUrl(self.cls.get(0).get("url"))
     self.logger.info(self.HttpUrl)
     self.Http.setParams(self.cls.get(0).get("params"))
     self.r = self.Http.get()
     self.r.status_code
     self.r.encoding = 'utf-8'
     self.logger.info("result-----------", self.r.json().get("errorCode"))
     assert self.r.status_code == 200, "请求失败"
     assert self.r.json().get("errorCode") == "0000000", "响应失败"
     self.imgCodeId = self.r.json().get("data").get("imgCodeId")
     self.confige.setReslConfig("imgCodeId", self.imgCodeId)
Пример #7
0
 def testLogin(self):
     """登陆"""
     self.cls = common.getXls("testCase.xlsx","test1")
     self.log = log.get_log()
     self.logger = self.log.getLogger()
     self.Http = configHttp.ConfigHttp()
     self.HttpUrl = self.Http.setUrl(self.cls.get(4).get("url"))
     self.logger.info(self.HttpUrl)
     TempParams = json.loads(self.cls.get(4).get("params"))
     self.readConfig = readConfig()
     TempParams["mobile"] = self.readConfig.getReslConfig("mobile")
     self.params =json.dumps(TempParams)
     self.logger.info(self.params)
     self.Http.setParams(self.params)
     self.r = self.Http.post()
     self.r.encoding = 'utf-8'
     self.logger.info("result-----------",self.r.json().get("errorCode"))
     assert self.r.status_code == 200,"请求失败"
     assert self.r.json().get("errorCode") == "0000000","响应失败"
     assert self.r.status_code == 200
Пример #8
0
def getChannelId():
    log = Log.get_log()
    logger = log.getLogger()
    #链接数据库
    db = ConfigDB.MyDB()
    db.connectDB()
    getChannelIdSql = get_sql("dzjk_user1", "usr_channel", "2")
    db.executeSQL(getChannelIdSql)
    ChannelId = db.getOne()
    if ChannelId:
        db.closeDB()
        return ChannelId[0]
    else:
        logger.info("获取ChannelId 报错!!!")
        db.closeDB()


# if __name__ == "__main__":
#     mobielIsExistSql = getChannelId()
#     print(mobielIsExistSql)
Пример #9
0
def MobileIsNotExist():
    log = Log.get_log()
    logger = log.getLogger()
    #链接数据库
    db = ConfigDB.MyDB()
    db.connectDB()
    mobielIsNotExist = False
    #获取sql
    mobielIsExistSql = get_sql("dzjk_user", "usr_info", "1")
    if mobielIsExistSql is not None:
        mobielIsExistSql = mobielIsExistSql.strip()
        #创建moblie
        c = CreateMobile.CreateMobile()
        mobile = c.create()
        mobielIsExistSql = mobielIsExistSql.replace("${mobile}", mobile)
        db.executeSQL(mobielIsExistSql)
        if not db.getOne():
            mobielIsNotExist = True
        else:
            mobielIsNotExist = False
    db.closeDB()
    return mobielIsNotExist
Пример #10
0
 def testApply(self):
     """身份认证"""
     self.cls = common.getXls("testCase.xlsx", "test1")
     self.log = log.get_log()
     self.logger = self.log.getLogger()
     self.Http = configHttp.ConfigHttp()
     self.HttpUrl = self.Http.setUrl(self.cls.get(5).get("url"))
     self.logger.info(self.HttpUrl)
     TempParams = json.loads(self.cls.get(5).get("params"))
     self.readConfig = readConfig()
     TempParams["idNum"] = self.readConfig.getReslConfig("idnum")
     TempParams["realName"] = self.readConfig.getReslConfig("realname")
     self.params = json.dumps(TempParams)
     self.logger.info(self.params)
     self.Http.setParams(self.params)
     self.Http.setHeaders("jwt", self.readConfig.getReslConfig("jwt"))
     self.r = self.Http.post()
     self.r.status_code
     self.r.encoding = 'utf-8'
     self.logger.info("result-----------", self.r.json().get("errorCode"))
     assert self.r.status_code == 200, "请求失败"
     assert self.r.json().get("errorCode") == "0000000", "响应失败"
Пример #11
0
    def __init__(self):
        global host, user, password, port, sender, title, content

        host = localReadConfig.getEmailConfig("mailHost")
        user = localReadConfig.getEmailConfig("mailUser")
        password = localReadConfig.getEmailConfig("mailPass")
        port = int(localReadConfig.getEmailConfig("port"))
        sender = localReadConfig.getEmailConfig("sender")
        title = localReadConfig.getEmailConfig("subject")
        content = localReadConfig.getEmailConfig("content")
        self.receiverValue = localReadConfig.getEmailConfig("receiver")
        self.onOff = localReadConfig.getEmailConfig("onOff")

        self.receiverList = []
        #获取收件人列表
        for receiver in str(self.receiverValue).split("/"):
            self.receiverList.append(receiver)
        #定义邮件发送时间
        date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        self.subject = title + " " + date
        self.log = log.get_log()
        self.logger = self.log.getLogger()
        self.msg = MIMEMultipart("mixed")
Пример #12
0
from Common import ReadConfig

from Common.Log import MyLog as Log

from Common import ConfigHttp

from Common import ConfigDB
from Common import CreateMobile

global rootPath

rootPath = ReadConfig.rootDir

localConfigHttp = ConfigHttp.ConfigHttp()

log = Log.get_log()
logger = log.getLogger()

#从excel文件中读取测试用例


def getXls(xlsName, sheetName):
    xlsNameValues = {}
    cls = []
    xlsPath = os.path.join(rootPath, "testFile", xlsName)
    file = open_workbook(xlsPath)

    sheet = file.sheet_by_name(sheetName)
    nRows = sheet.nrows
    clsTitileName = sheet.row_values(0)
    for i in range(nRows):
Пример #13
0
    def __init__(self):
        self.log = log.get_log()
        self.logger = self.log.getLogger()

        self.db = None
        self.cursor = None