예제 #1
0
class element_Search(unittest.TestCase):
    log = logger.Log()

    def setUp(self):

        s = requests.session()
        self.s = s
        self.login = login214.Login(s).login()

    def test_search(self):
        self.log.info('开始测试')
        url2 = "http://192.168.0.241:8080/device/search"
        datas = {"pageNumber": "1", "pageSize": "10", "keywords": ""}
        head2 = {
            "User-Agent":
            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36",
            "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
        }
        self.log.info('登录成功')

        r2 = self.s.post(url=url2,
                         data=datas,
                         headers=head2,
                         allow_redirects=False)
        self.log.info('设备接口响应')
        self.assertEqual(200, r2.status_code)
        self.log.info('响应结果:' + str(r2.status_code))
        data = r2.json()
        self.assertEqual(0, data['total'])
        self.log.info('设备总数:' + str(data['total']))
예제 #2
0
 def setUpClass(cls):
     cls.dates = commons.commonMethod().readExcel('test_submitOrder.xlsx',
                                                  'Sheet1')
     cls.testUrl = cls.dates[0][0]
     cls.testmethod = cls.dates[1][0]
     cls.log = logger.Log('submitOrder')
     cls.logger = cls.log.getLog('test_SubmitOrder_interface')
예제 #3
0
 def setUpClass(cls):
     cls.dates = commons.commonMethod().readExcel('Lsh_Interface.xlsx','Test_Sale_Funnel_Operation')
     cls.dates_new = commons.commonMethod().readNewExcel('testcase.xlsx')
     cls.testUrl = cls.dates[0][0]
     cls.testmethod = cls.dates[1][0]
     cls.log = logger.Log('salesFunnelOperation')
     cls.logger = cls.log.getLog('test_salesFunnelOperation_interface')
 def setUpClass(cls):
     cls.dates = commons.commonMethod().readExcel(
         'Lsh_Interface.xlsx', 'Sales_Management_Report')
     #cls.dates_new = commons.commonMethod().readNewExcel('testcase.xlsx')
     cls.testUrl = cls.dates[0][0]
     cls.testmethod = cls.dates[1][0]
     cls.log = logger.Log('salesManagementReport')
     cls.logger = cls.log.getLog('test_ManagementReport_interface')
예제 #5
0
def get_report_file(report_path):
    '''第三步:获取最新的测试报告'''
    lists = os.listdir(report_path)
    lists.sort(key=lambda fn: os.path.getmtime(os.path.join(report_path, fn)))
    logger.Log().info("最新测试报告:" + lists[-1])
    # 找到最新生成的测试报告
    report_file = os.path.join(report_path, lists[-1])
    return report_file
예제 #6
0
class HttpRquest(object):
    log = logger.Log()
    res= {}
    def http_request(self,method,url,param,header,cookies):
        """
        :param method: 请求类型
        :param url:    请求地址
        :param param:  请求参数
        :param header:  请求头部
        :param cookies:
        :return:  请求结果
        """
        if method.upper() == 'GET':
            try:
                self.res = requests.get(url, params=param, headers=header,cookies=cookies)
            except Exception as e:
                self.log.error('报错啦:{0}'.format(e))
        elif method.upper() == 'POST':
            try:
                self.res = requests.post(url, json=param,  headers=header,cookies=cookies)
            except Exception as e:
                self.log.error('报错啦:{0}'.format(e))
        elif method.upper() == 'PUT':
            try:
                self.res = requests.put(url, json=param, headers=header, cookies=cookies)
            except Exception as e:
                self.log.error('报错啦:{0}'.format(e))
        elif method.upper() == 'DELETE':
            try:
                self.res = requests.delete(url, data=param, headers=header, cookies=cookies)
            except Exception as e:
                self.log.error('报错啦:{0}'.format(e))
        else:
            self.log.info('请求方式错误')

        return  self.res

    def __jsonpr(self, url, method ,*args, **kwags):
        '''测试执行http请求'''
        headers={'content-type':'application/json'}
        self.payload={
            "jsonprc":"2.0",
            "id":uuid.uuid4().hex,
            "method":method,
            "params":args if args else kwags

        }
        response=requests.post(url,json=self.payload,headers=headers)
        try:
            self.res = response.json()
        except Exception as e:
            self.res = None
        finally:
            # a=inspect.stack()[1][3]
            # self.description=cls.__class__.__dict__[a].__doc__
            # self.url = url
            # self.headers = headers
            return self.res
예제 #7
0
def get_token(result):
    """
    获取登录token
    :param r: 查询结果集
    :return:token
    """
    try:
        url = config.h5_url + str(result[0][1])
        logger.Log().info("登录url:{}".format(url))
        headers = eval(result[0][4])
        logger.Log().info("登录header:{}".format(headers))
        body = eval(result[0][2])
        logger.Log().info("登录body:{}".format(body))
        re = requests.post(url=url, headers=headers,
                           data=json.dumps(body)).json()
        logger.Log().info("登录结果:{}".format(re))
        return re['data']['token']
    except Exception as e:
        logger.Log().info("登录异常:{}".format(e))
        raise
예제 #8
0
    def __init__(self):
        # Log
        attack_log_filename = os.path.join(log_dir, "attack.log")
        self.attack_log = logger.Log(attack_log_filename, auto_timestamp=0)
        self.attack_log.set_print_level(
            3)  # Only print the attacking message but not the event message.

        center_log_filename = os.path.join(log_dir, "center.log")
        self.center_log = logger.Log(center_log_filename)

        # Honeypots and Globalpot
        self.honeypots = {}  #{'name'-> [conf, thread_instance]}
        self.globalpot_cfg = None

        # Message management
        self.msg_queue = Queue()

        self.msg_handler = threading.Thread(target=self.handle_msg)
        self.msg_handler.setDaemon(True)
        self.msg_handler.start()

        # Handle the event message, sometimes will generate an attack message.
        self.event_handler = event.Analysis(self.msg_queue, self.honeypots)
예제 #9
0
class user_Search(unittest.TestCase):
    log = logger.Log()

    def setUp(self):
        s = requests.session()
        self.s = s
        self.login = login214.Login(s).login()

    def test_usersearch(self):
        self.log.info('开始测试人员管理查询')
        url = 'http://192.168.0.241:8080/system/user/search'
        data = {"pageNumber": "1", "pageSize": "10", "keywords": ""}
        r = self.s.post(url, data=data, verify=False)
        self.assertEqual(200, r.status_code)
        self.log.info('响应为' + str(r.status_code))
        result = r.json()
        self.assertEqual(929, result['total'])
        self.log.info('人员总数为' + str(result['total']))
예제 #10
0
 def __init__(self):
     self.sit_host = readConfig().getDB('sit_host')
     self.sit_username = readConfig().getDB('sit_username')
     self.sit_password = readConfig().getDB('sit_password')
     self.sit_port = readConfig().getDB('sit_port')
     self.sit_db_name = readConfig().getDB('sit_db_name')
     self.environment = readConfig().getDB('environment')
     self.ssh_address_or_host = readConfig().getDB('ssh_address_or_host')
     self.ssh_address_port = readConfig().getDB('ssh_address_port')
     self.ssh_username = readConfig().getDB('ssh_username')
     self.ssh_password = readConfig().getDB('ssh_password')
     self.demo_host = readConfig().getDB('demo_host')
     self.demo_username = readConfig().getDB('demo_username')
     self.demo_password = readConfig().getDB('demo_password')
     self.demo_db_name = readConfig().getDB('demo_db_name')
     self.demo_port = readConfig().getDB('demo_port')
     self.log = logger.Log('Connect_DB')
     self.mylog = self.log.getLog('ConnectDB_LOG')
예제 #11
0
파일: asserts.py 프로젝트: xcntest/dynamic
 def __init__(self, sqlpath, dbconn):
     """
     :param connpath: 数据库信息配置文件路径
     :param connsection: 数据库类型section
     :param sqlpath: sql文件存放路径
     """
     # 获取数据库连接对象
     # self.conninfo = readfiles.read_yaml(connpath, connsection)
     # self.dbconn = mysqlconn.DBOperate(self.conninfo)
     self.dbconn = dbconn
     self.sqlpath = sqlpath
     self.strlist = [
         'char', 'varchar', 'binary', 'varbinary', 'enum', 'set'
     ]
     self.numlist = [
         'int', 'interger', 'tinyint', 'smallint', 'mediumint', 'bigint',
         'serial'
     ]
     self.datelist = ['date', 'year', 'timestamp', 'time', 'datatime']
     self.floatlist = ['numeric', 'decimal']
     self.otherlist = ['tinyblob', 'blob', 'mediumblob', 'longtext', 'bit']
     self.logger = logger.Log()
예제 #12
0
def read_yaml(filepath,section:str):
    """
    :param filepath: 文件路径
    :return: 文件内容
    """
    #拼接根目录+文件子路径
    loger = logger.Log()
    #TODO 这里要修改一下读取方式
    #运行main为run.py
    filename = Path.cwd().joinpath(filepath)
    #运行main为非run.py
    #filename = Path.cwd().parent.joinpath(filepath)

    if not Path.exists(filename):
        loger.error("文件不存在")

    with open(filename,encoding='utf-8') as f:
       data = yaml.load(f)
       try:
            yamlinfo = filetools.AttrDict(data[section])
       except Exception as e:
            print(e)
            loger.error('传入的section错误,传入值为{}'.format(e))
    return yamlinfo # 返回的是个AttrDict字典
예제 #13
0
def send2session():
    s = requests.Session()
    log = logger.Log()
    loginfo = readfiles.read_yaml('interinfo/login.yaml', 'login')
    host = readfiles.read_yaml('interinfo/basic.yaml', 'mainhost').host
    password = encryptpwd.pwd_encryptwd(loginfo.data['j_password'])
    loginfo.data['j_password'] = password
    vcode = getvcode.GetVcode().baiduOCR()
    url = 'https://' + host + loginfo.url
    #TODO 这个循环逻辑好像有点问题,完成后尝试优化
    while True:
        while vcode is None or len(vcode) < 4:
            vcode = getvcode.GetVcode().baiduOCR()
        else:
            loginfo.data['verCode'] = vcode
            response = s.post(url=url,
                              data=loginfo.data,
                              headers=loginfo.headers,
                              verify=False)
            log.info(loginfo.data)
            if response.status_code == 200:
                print(response.status_code)
                return s
                break
예제 #14
0
 def setUp(self):
     # self.token = get_token.GetRes().get_res()
     self.log = logger.Log()
예제 #15
0
 def setUp(self):
     self.log = logger.Log()
예제 #16
0
 def __init__(self, env):
     self.env = env
     self.log = logger.Log()
     self.header = headerconfig.Platform(env)
예제 #17
0
#    author:zhangxin      #
#      time:20210105      #
# ----------------------- #
import pytest
import allure
from MINIapp import shopplanlist
from common import logger
from config import env, dbconf, readConfig
import time, datetime

ev = env.QA

plist = shopplanlist.shopplanList(ev)

db = dbconf.DataLoader(ev)
log = logger.Log()

# 获取用户id和token
plist.header.user_id = readConfig.user_id
plist.header.user_token = readConfig.user_token

sql = "SELECT id FROM syds_shop.public.sp_shop ORDER BY id DESC"
db.sql_connect("shop", sql)
shopid = db.cur.fetchone()[0]
case_list = [(0, 20, shopid, True)]


@allure.feature('V1.1.1 直播预告(一个店铺下的直播预告列表)')
@allure.description('V1.1.1 直播预告(一个店铺下的直播预告列表)')
@allure.story('V1.1.1 直播预告(一个店铺下的直播预告列表)')
@allure.title('V1.1.1 直播预告(一个店铺下的直播预告列表)')
예제 #18
0
파일: getvcode.py 프로젝트: xcntest/dynamic
 def __init__(self):
     self.dir = os.path.join(
         os.path.split(os.path.dirname(__file__))[0], 'images')
     #获取图片接口
     self.url = 'https://192.168.230.121/capaa/v1/user/verification/image'
     self.log = logger.Log()
예제 #19
0
def loggingcreate():
    filename = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(
        time.time())) + '.log'
    logger1 = logger.Log("zzz", filename)
    return logger1
예제 #20
0
        return re['data']['token']
    except Exception as e:
        logger.Log().info("登录异常:{}".format(e))
        raise


def database(database, scenes):
    """
    数据库查询数据
    :param database:数据库文件路径
    :param scenes:场景名称
    :return:查询结果集
    """
    try:
        conn = sqlite3.connect(database)
        cur = conn.cursor()
        sql = "SELECT * FROM testscenes WHERE scenes=" + scenes + ';'
        cur.execute(sql)
        result = cur.fetchall()
        conn.close()
        return result
    except Exception as e:
        logger.Log.info("数据库异常:{}".format(e))
        raise


if __name__ == '__main__':
    result = database(config.database, "'登录'")
    respones = get_token(result)
    logger.Log().info("获取token成功 :{}".format(respones))
예제 #21
0
 def setUp(self):
     self.log = logger.Log()
     self.res = get_res.GetRes().get_res().text  # 调用get_res模块,获取包含token的响应
     self.token = eval(self.res)["data"]["token"]  # 获取token
예제 #22
0
 def __init__(self):
     self.log = logger.Log()