Пример #1
0
"""
import unittest
import paramunittest
import urllib.parse
import time

# 导入相应的方法
from testFile.geturlParams import geturlParams
from testFile.readConfig import ReadConfig
from testFile.readExcel import readExcel
from common.configHttp import RunMain
from common.util import Utility
from common.configDB import DB

# 实例化参数
readconfig = ReadConfig()
addProjectAudit_xls = readExcel().get_xls('userCase.xlsx', 'addProjectAudit')
util = Utility()
db = DB()
# 准备数据
# del_sql = "delete from m_project_member where p_id=673 and user_id=15"
# query_sql = "select * from m_project_member where p_id=673 and user_id=15"
file = "../testFile/sqlFile/m_project_member"
f = open(file, "r")
read_data = f.readlines()
@paramunittest.parametrized(*addProjectAudit_xls)
class addProjectAudit(unittest.TestCase):
    # 实例化Excel表中的数据
    def setParameters(self, case_no, case_name, path, parameter, method, expect_result, expect_content):
        """
               :param case_no:
Пример #2
0
# #!/usr/bin/env python

import pprint

from pymongo import MongoClient

from testFile.readConfig import ReadConfig

readConfig = ReadConfig()

host = ReadConfig().get_MongoDB('host')

port = ReadConfig().get_MongoDB('port')

username = ReadConfig().get_MongoDB('username')

password = ReadConfig().get_MongoDB('password')

database = ReadConfig().get_MongoDB('database')


class MainMongodb(object):
    def __init__(self,
                 host=host,
                 port=port,
                 username=username,
                 password=password,
                 database=database):
        """

        初始化
Пример #3
0
"""
读取Excel中的测试用例,使用unittest来进行断言
"""
import unittest
import paramunittest
import urllib.parse
import time


from testFile.geturlParams import geturlParams
from testFile.readConfig import ReadConfig
from testFile.readExcel import readExcel
from common.configHttp import RunMain
from common.util import Utility
from common.configDB import DB
readconfig = ReadConfig()
taskTypeInfo_xls = readExcel().get_xls('userCase.xlsx','taskTypeInfo')
util = Utility()
db=DB()
headers = {'token':readconfig.get_token('token'),'userid':readconfig.get_userid('userid')}

@paramunittest.parametrized(*taskTypeInfo_xls)
class testTaskTypeInfo(unittest.TestCase):
    def setParameters(self, case_no, case_name, path, parameter, method, expect_result, expect_content):
        """
               :param case_no:
               :param case_name:
               :param parameter:
               :param method:
               :param expect_result:
               :param path:
Пример #4
0
"""
这个文件主要来通过get、post、put、delete等方法进行http请求,并拿到请求响应
"""

import requests
from testFile.readConfig import ReadConfig

readconfig = ReadConfig()
headers = {
    'token': readconfig.get_token('token'),
    'userid': readconfig.get_userid('userid')
}


class RunMain():
    def send_post(self, url=None, data=None, files=None):
        # 封装post请求,参数按照顺序传入
        result = requests.post(url=url,
                               headers=headers,
                               data=data,
                               files=files)  # 因为这里要封装post方法,所以这里的url和data值不能写死
        # res = json.dumps(result.json(), ensure_ascii=False, sort_keys=True,separators=(',',':'))
        return result

    def send_get(self, url=None, data=None):
        result = requests.get(url=url, params=data, headers=headers)
        # result = json.dumps(result, ensure_ascii=False, sort_keys=True, indent=2)
        return result

    def run_main(
        self,
Пример #5
0
 def __init__(self, excle_name, sheet_name):
     self.excle_name = excle_name
     self.sheet_name = sheet_name
     self.readConfig = ReadConfig()
     self.readExcle = ReadExcle(excle_name, sheet_name)
Пример #6
0
class ReadCase:
    def __init__(self, excle_name, sheet_name):
        self.excle_name = excle_name
        self.sheet_name = sheet_name
        self.readConfig = ReadConfig()
        self.readExcle = ReadExcle(excle_name, sheet_name)

    def set_excle_name(self, excle_name):
        self.excle_name = excle_name

    def set_sheet_name(self, sheet_name):
        self.sheet_name = sheet_name

    def get_sheet_name(self):
        return self.sheet_name

    def get_excle_name(self):
        return self.excle_name

    """根据用例名称获取接口地址 , 协议 +host + port + path"""
    def get_interface_url(self, case_name, isTest=False):
        if isTest == False:
            try:
                new_url = self.readConfig.get_http('scheme') + '://' + self.readConfig.get_http('host') + ":" + self.readConfig.get_http('port') + self.get_path(case_name)
                return new_url
            except Exception as e:
                print(e)
                print("用例名称不存在1,或输入错误,请检查!!!")
        else:
            try:
                new_url = self.readConfig.get_ml('scheme') + '://' + self.readConfig.get_ml('host') + ":" + self.readConfig.get_ml('port') + self.get_path(case_name)
                return new_url
            except Exception as e:
                print(e)
                print("用例名称不存在2,或输入错误,请检查!!!")

    def get_interface_data(self, case_name):
        try:
            for i in range(0, self.readExcle.ncols - 1):
                row_value = self.readExcle.get_excle()[i][0]
                if case_name == row_value:
                    return self.readExcle.get_excle()[i][2]
        except Exception as e:
            print(e)
            print("data对应用例名称不存在,或输入错误,请检查!!!")

    def get_intetface_headers(self, case_name):
        try:
            for i in range(0, self.readExcle.ncols - 1):
                row_value = self.readExcle.get_excle()[i][0]
                if case_name == row_value:
                    return self.readExcle.get_excle()[i][3]
        except Exception as e:
            print(e)
            print("Headers用例名称不存在,或输入错误,请检查!!!")

    """根据用例名称返回这个用例所对应的path路径"""
    def get_path(self, case_name):
        for i in range(0, self.readExcle.ncols - 1):
            row_value = self.readExcle.get_excle()[i][0]
            if case_name == row_value:
                return self.readExcle.get_excle()[i][1]