Exemplo n.º 1
0
 def get_duojia_data_info(self, casename):
     Ereader = ExcelReader(sheet='duojia',
                           excel=YamlReader('config.yml').get_data('data'))
     data = Ereader.get_value(casename)
     url = data['url']
     params = json.loads(data['params'])
     method = data['method']
     return url, params, method
Exemplo n.º 2
0
 def __init__(self,
              method,
              host=YamlReader('config.yml').get_data('env'),
              timeout=60):
     self.method = method
     #设置超时时间
     self.host = host
     self.timeout = timeout
     self.headers = {}
     self.data = {}
     self.params = {}
Exemplo n.º 3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/1/28 上午10:32
# @Author  : huanghe
# @Site    :
# @File    : cookie_manage.py
# @Software: PyCharm
#获取用户cookie并存储
import requests
from utils.path import Path
from utils.file_manage import YamlReader

offline_mobile = YamlReader('config.yml').get_data('User').get('mul_user')
offline_pwd = YamlReader('config.yml').get_data('User').get('mul_pwd')
single_mobile = YamlReader('config.yml').get_data('User').get('single_user')
single_pwd = YamlReader('config.yml').get_data('User').get('single_pwd')
url_pwd_url = 'https://www.zhbbroker.com/yiiapp/user-pwd/user-pwd-login?mobile=' + str(
    offline_mobile) + '&pwd=' + offline_pwd
url_pwd_url_s = 'https://www.zhbbroker.com/yiiapp/user-pwd/user-pwd-login?mobile=' + str(
    single_mobile) + '&pwd=' + single_pwd


#type 1 多家 2 单家
def set_pwd_cookie(type):

    if str(type) == '2':
        url = url_pwd_url_s
    else:
        url = url_pwd_url
    s = requests.session()
    response = s.post(url)
Exemplo n.º 4
0
def get_xubao(
    filename,
    province,
    city,
    iscity,
    district,
    date,
    company='',
):
    province = province
    city = city
    company = company
    district = district
    config = YamlReader('config.yml')
    date = date
    host = config.get_data('mysql').get('host')
    port = config.get_data('mysql').get('port')
    user = config.get_data('mysql').get('user')
    passwd = config.get_data('mysql').get('passwd')
    db = config.get_data('mysql').get('db')
    helper = MysqlHelper(host=host, port=port, db=db, user=user, passwd=passwd)
    #result = helper.get_xubao(province,city,data)
    if iscity == 1:
        liben = get_li_beg(province=province, city=city) + '%'
        result = helper.get_xubao(province=province,
                                  city=liben,
                                  company=company,
                                  date=date)
    else:
        result = helper.get_xubao(province=province,
                                  company=company,
                                  date=date)
    if len(result) == 0:
        dictdata = {'engine_no': '', 'seat_num': ''}
    else:
        dictdata = result[0]
    print(dictdata)
    dictinsure = config.get_data('insured')
    dictdata = dict(dictdata, **dictinsure)
    dictdata['version'] = config.get_data('app').get('version')
    dictdata['insurance_company'] = company
    dictdata['city'] = city
    if dictdata['engine_no'] == '':
        dictdata['engine_no'] = '321352'
    if dictdata['seat_num'] == 0:
        dictdata['seat_num'] = 4
    dictdata['district'] = district
    dictdata['addressee_name'] = '张汉'
    dictdata['addressee_mobile'] = '17621100888'
    dictdata['addressee_province'] = province
    dictdata['addressee_city'] = city
    dictdata['addressee_area'] = district
    dictdata['addressee_detail'] = '南京路新华小区102室'
    dictdata['insured_mobile'] = '17621100888'
    dictdata['applicant_mobile'] = '17621100888'
    dictdata['owner_mobile'] = '17621100888'
    dictdata['insured_province'] = province
    dictdata['insured_city'] = city
    dictdata['insured_district'] = district
    dictdata['insured_detail'] = '南京路新华小区102室'
    impl = minidom.getDOMImplementation()
    doc = impl.createDocument(None, None, None)
    rootElement = doc.createElement('dates')
    for key, value in dictdata.items():
        # 创建子元素
        childElement = doc.createElement('date')
        # 为子元素添加id属性
        childElement.setAttribute('name', str(key))
        childElement.setAttribute('value', str(value))
        # 将子元素追加到根元素中
        rootElement.appendChild(childElement)
        # 将拼接好的根元素追加到dom对象
        doc.appendChild(rootElement)
        # 打开test.xml文件 准备写入
    filename = os.path.join(Path().get_data_path(), filename)
    f = open(filename, 'w', encoding='UTF-8')
    # 清空数据
    f.seek(0)
    f.truncate()
    # 写入文件
    doc.writexml(f, addindent=' ', newl='\n', encoding='UTF-8')
    # 关闭
    f.close()
Exemplo n.º 5
0
def get_xubao_xml(
    filename,
    province,
    city,
    iscity,
    district,
    date,
    company='',
):
    config = YamlReader('config.yml')
    reader = ExcelReader('suzhou_single.xls')
    n = int(YamlReader('num.yml').get_data('num'))
    dictdata = reader.data[n]
    #记录+1
    n = n + 1
    YamlReader('num.yml').set_data(n)
    dictinsure = config.get_data('insured')
    dictdata = dict(dictdata, **dictinsure)
    dictdata['version'] = config.get_data('app').get('version')
    dictdata['insurance_company'] = company
    dictdata['city'] = city
    if dictdata['engine_no'] == '':
        dictdata['engine_no'] = '321352'
    if dictdata['seat_num'] == 0:
        dictdata['seat_num'] = 4
    dictdata['district'] = district
    dictdata['addressee_name'] = '张汉'
    dictdata['addressee_mobile'] = '17621100888'
    dictdata['addressee_province'] = province
    dictdata['addressee_city'] = city
    dictdata['addressee_area'] = district
    dictdata['addressee_detail'] = '南京路新华小区102室'
    dictdata['insured_mobile'] = '17621100888'
    dictdata['applicant_mobile'] = '17621100888'
    dictdata['owner_mobile'] = '17621100888'
    dictdata['insured_province'] = province
    dictdata['insured_city'] = city
    dictdata['insured_district'] = district
    dictdata['insured_detail'] = '南京路新华小区102室'
    impl = minidom.getDOMImplementation()
    doc = impl.createDocument(None, None, None)
    rootElement = doc.createElement('dates')
    for key, value in dictdata.items():
        # 创建子元素
        childElement = doc.createElement('date')
        # 为子元素添加id属性
        childElement.setAttribute('name', str(key))
        childElement.setAttribute('value', str(value))
        # 将子元素追加到根元素中
        rootElement.appendChild(childElement)
        # 将拼接好的根元素追加到dom对象
        doc.appendChild(rootElement)
        # 打开test.xml文件 准备写入
    filename = os.path.join(Path().get_data_path(), filename)
    f = open(filename, 'w', encoding='UTF-8')
    # 清空数据
    f.seek(0)
    f.truncate()
    # 写入文件
    doc.writexml(f, addindent=' ', newl='\n', encoding='UTF-8')
    # 关闭
    f.close()
Exemplo n.º 6
0
 def __init__(self, loggername):
     self.logger = logging.getLogger(loggername)
     logging.root.setLevel(logging.NOTSET)
     c = YamlReader('config.yml').get_data('log')
     self.log_file_name = c.get(
         'file_name') if c and c.get('file_name') else 'test.log'  # 日志文件
     self.backup_count = c.get(
         'backup') if c and c.get('backup') else 5  # 保留的日志数量
     # 日志输出级别
     self.console_output_level = c.get(
         'console_level') if c and c.get('console_level') else 'WARNING'
     self.file_output_level = c.get(
         'file_level') if c and c.get('file_level') else 'DEBUG'
     # 日志输出格式
     pattern = c.get('pattern') if c and c.get(
         'pattern'
     ) else '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
     self.formatter = logging.Formatter(pattern)
Exemplo n.º 7
0
def env(request):
    env_config = YamlReader('config.yml').get_data('env')
    allure.environment(host=env_config)
    return env_config
Exemplo n.º 8
0
#pytest_plugins = 'allure.pytest_plugin'
@pytest.fixture
def record_common_car_info():
    url = (ExcelReader(sheet=3, excel=Config().get('data')).data)[0]['url']
    params = (ExcelReader(sheet=3, excel=Config().get('data')).data)[0]['params']
    method = (ExcelReader(sheet=3, excel=Config().get('data')).data)[0]['method']
    return url,params,method
    '''
import pytest
import allure
from utils.file_manage import ExcelReader
from utils.file_manage import YamlReader
import json

Ereader = ExcelReader(sheet=3, excel=YamlReader('config.yml').get_data('data'))


@pytest.fixture
def make_customer_record():
    def _make_customer_record(name):
        return {"name": name, "order": []}

    return _make_customer_record


@pytest.fixture
def get_data_info():
    def _get_data_info(casename):
        data = Ereader.get_value(casename)
        url = data['url']