Exemple #1
0
import unittest
import paramunittest
import readConfig as readConfig
from common import Log as Log
from common import common
from common import configHttp as ConfigHttp

login_xls = common.get_xls("userCase.xlsx", "login")
localReadConfig = readConfig.ReadConfig()
configHttp = ConfigHttp.ConfigHttp()
info = {}


@paramunittest.parametrized(*login_xls)
class Login(unittest.TestCase):
    def setParameters(self, case_name, method, token, email, password, result,
                      code, msg):
        """
        set params
        :param case_name:
        :param method:
        :param token:
        :param email:
        :param password:
        :param result:
        :param code:
        :param msg:
        :return:
        """
        self.case_name = str(case_name)
        self.method = str(method)
__author__ = "JunChao"
import readConfig as readConfig
from common.Log import MyLog
from common import configHttp
from common import common
import unittest
import paramunittest
from common import configDB

register_xls = common.get_xls("userCase.xlsx", "register")
localConfigHttp = configHttp.ConfigHttp()
localReadConfig = readConfig.ReadConfig()
localConfigDB = configDB.MyDB()


@paramunittest.parametrized(*register_xls)
class Register(unittest.TestCase):
    def setParameters(self, case_name, method, token, email, password,
                      confirmpwd, result, code, msg):
        """
        set parameters
        :param case_name:
        :param method:
        :param token:
        :param email:
        :param password:
        :param confirmpwd:
        :param result:
        :param code:
        :param msg:
        :return:
'''
开放平台
Merchant API 发送交易 Rawtx
'''
import readConfig
import json
import unittest
from common import common, Log
import paramunittest
from common import configHttp, configDing

TxRawtx_xls = common.get_xls('OpenApiCase.xlsx', 'tx_Rawtx')
localReadConfig = readConfig.ReadConfig()
configHttp = configHttp.ConfigHttp()
info = {}


@paramunittest.parametrized(*TxRawtx_xls)
class TXRawtx(unittest.TestCase):
    def setParameters(self, case_name, method, headers, data, code, msg):

        self.case_name = str(case_name)
        self.method = str(method)
        self.headers = json.loads(headers)
        self.data = json.loads(data)
        self.code = str(code)
        self.msg = str(msg)

    def setUp(self):
        self.log = Log.MyLog.get_log()
        self.logger = self.log.get_logger()
Exemple #4
0
    def test01_listRepairUsers(self):

        #依賴其他接口參數
        get_xls = commons.get_xls("caseforparame.xlsx", "Addrepair")
        try:
            xls_01 = get_xls[0]
            xls_02 = get_xls[1]
        except:
            print("超出列表值")
        xls_reponses = get_xls[0][-1]
        xls_reponse = json.loads(xls_reponses)

        localReadConfig = readConfig.ReadConfig()
        configHttp = ConfigHttp.ConfigHttp()
        info = {}
        Authorization_id = commons.get_Authorization()


        # set url
        self.repairId = commons.get_parameter_from_xls(xls_reponse, "id", None)
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('listRepairUsers')
        #+"keywords="+self.keywords+ "&"+"maxPageItems="+self.maxPageItems+"&"

        self.url_new = self.url+"?"+"repairId="+str(self.repairId)
        configHttp.set_url(self.url_new)
        print("第一步:设置url  "+self.url_new)

        # get visitor token
        # if self.token == '0':
        #     token = localReadConfig.get_headers("token_v")
        # elif self.token == '1':
        #     token = None

        #set headers
        Content_Type = localReadConfig.get_headers('Content-Type')
        no_cache = localReadConfig.get_headers('Cache-Control')
        header = {'Authorization':Authorization_id,'Cache-Control':no_cache}
        print('header%s ' % header )
        configHttp.set_headers(header)
        print("第二步:设置header等")



        # set params
        # data = {
        #     "keywords":self.keywords,
        #     "maxPageItems": self.maxPageItems,
        #     "offsetStart": self.offsetStart,
        #     "repairId ":self.repairId
        # }
        # DATE = json.dumps(data)
        # print('DATE%s' % DATE)
        # configHttp.set_params(DATE)
        print("第三步:设置发送请求的参数")
        self.logger.info("********creater********")

        # test interface
        try:
            self.return_json = configHttp.get()
        except Exception as e:
            print('e %s' % e)
        method = str(self.return_json.request)[int(str(self.return_json.request).find('['))+1:int(str(self.return_json.request).find(']'))]
        print("第四步:发送请求\n\t\t请求方法:"+method)

        print("第五步:检查结果")
        self.checkResult()
        return self.return_json
from common import configHttp
import readConfig
from common.BasePage import BasePage

localReadConfig = readConfig.ReadConfig()  #初始化读取配置信息类
configHttp = configHttp.ConfigHttp()  #初始化http信息


class setParameters:
    def setParameters(cls, data):
        '''
       定义变量接收值
       '''
        print(
            "*******************************************************************************************************"
        )
        if '用例名' in data:
            cls.case_name = str(data['用例名'])
            setParameters.dataprint('测试用例数据:%s' % cls.case_name)
        if 'result' in data:
            cls.result = str(data['result'])
        if 'method' in data:
            cls.method = str(data['method'])  # 请求方法
        if 'url' in data:
            cls.url = str(data['url'])
        if 'code1' in data:
            cls.code1 = str(data['code1'])
        if 'code2' in data:
            cls.code2 = str(data['code2'])
            setParameters.dataprint(cls.code2)
        if 'code3' in data:
Exemple #6
0
import unittest
import readConfig
from common import common
from common import configHttp
from common import ConnectDB

rc = readConfig.ReadConfig()
cf = configHttp.ConfigHttp()
cd = ConnectDB.Mongo_DB()


class BR(unittest.TestCase):
    def setUp(self):
        self.url = rc.get_http("baseurl")
        self.header = eval(rc.get_http("header"))
        self.database = rc.get_mongo("database")
        self.mongo_client = cd.get_mongoConnect()

    def request_url(self):
        self.data = {
            "context": {
                "id_card_number": "341124199108145313",
                "mobile": "18552272190",
                "name": "高学朋",
                "decision_time": "2019-06-28 22:35:47",
                "usage": "offline"
            },
        }
        self.element_id = common.Read_xlrd.get_xls("百融因子20190620.xlsx",
                                                   "bairong")
        print(self.element_id)
Exemple #7
0
import redis
from common import configHttp
from common import rsa_aes
import readConfig
from common import Log
config = readConfig.ReadConfig()
content = configHttp.ConfigHttp()
log=Log.Log()
a=rsa_aes.Rsa()

# 获取图形验证码
def getcapture():
    pool = redis.ConnectionPool(host=config.get_redis('yc_host'), password=config.get_redis('yc_password'))
    r = redis.Redis(connection_pool=pool)
    content.set_url("/property/api/v1/user/getCaptcha")
    req=content.get()
    # 获取sessionid
    ssion=req.headers['Set-Cookie'].split(';')[0].split('=')[1]
    tuxing = r.get("YC:PROPERTY:USER:CAPTCHA:%s"%ssion)
    tx=str(tuxing, encoding='utf-8')
    return [tx,req.cookies]

[tx,session]=getcapture()

# 忘记登录密码,不加密
def forgotpwd(mobile, newPwd, confirmpwd,smscode='000000',utype=1,code=tx):
    """
    :param mobile:手机号
    :param newPwd:新密码
    :param confirmpwd:确认密码
    :param code:图形验证码
Exemple #8
0
import unittest
import paramunittest
import readConfig as readConfig
from common import Log as Log
from common import units
from common import configHttp as ConfigHttp

configSave_xls = units.get_xls('configData.xlsx', 'save')
localReadConfig = readConfig.ReadConfig()
localConfigHttp = ConfigHttp.ConfigHttp()
info = {}


@paramunittest.parametrized(*configSave_xls)
class SdataSave(unittest.TestCase):
    def setParameters(self, case_name, method, configId, nameX, nameY, nameZ,
                      value1, value2, result, code, msg):
        """
        set params
        :param case_name:
        :param method:
        :param configId:
        :param nameX:
        :param nameY:
        :param nameZ:
        :param value1:
        :param value2:
        :param result:
        :param code:
        :param msg:
        :return:
Exemple #9
0
import requests
import readConfig
import os
import re
from xlrd import open_workbook
from xml.etree import ElementTree as ElementTree
from common import configHttp
from common.Log import MyLog
import json

localReadConfig = readConfig.ReadConfig()            #初始化读取配置信息的类
proDir = readConfig.proDir                           #读取配置信息类中,根目录地址相当于这里的接口测试文档框架路径
localConfigHttp = configHttp.ConfigHttp()            #配置接口类,进行接口配置信息初始化
log = MyLog.get_log()                                #启动MyLog的get_log方法开启锁,get_log中又启动Log进行初始化
logger = log.get_logger()                            #获取记录     log最后代码一样

caseNo = 0


def get_visitor_token():
    """为访问者创建一个令牌
    create a token for visitor
    :return:
    """                                                #相当于先用get去获取网站的访问令牌
    host = localReadConfig.get_http("BASEURL")         #获取路径
    port = localReadConfig.get_http("port")             #获取端口
    url = get_url_from_xml('login')              #端口后路径
    response = requests.get(host+':'+port+'/'+url)
    info = response.json()
    token = info.get("info")
    logger.debug("Create token:%s" % (token))