def run_tihuoshenqingchaxun_data():
    path = cases_path.get('tihuoshenqingchaxun_data')
    dis = unittest.TestLoader()
    cases = dis.discover(path, pattern='*.py')

    now = datetime.now()
    report_file = open(report_every.format(
        report_name.get('tihuoshenqingchaxun_data')),
                       'w',
                       encoding='utf8')
    runner_tihuoshenqing_data = HTMLTestRunner(
        stream=report_file,
        title=report_name.get('tihuoshenqingchaxun_data'),
        description='配货项目测试报告')
    runner_tihuoshenqing_data.run(cases)
Ejemplo n.º 2
0
def run_apply():

    path = cases_path.get('apply')
    dis = unittest.TestLoader()
    cases = dis.discover(path, pattern='*.py')

    now = datetime.now()
    report_file = open(report_every.format(report_name.get('apply')),
                       'w',
                       encoding='utf8')
    runner_buy_count = HTMLTestRunner(stream=report_file,
                                      title=report_name.get('apply'),
                                      description='配货项目测试报告')

    runner_buy_count.run(cases)
Ejemplo n.º 3
0
def run_fabu():
    path = cases_path.get('fabu')
    dis = unittest.TestLoader()
    cases = dis.discover(path, pattern='*.py')

    now = datetime.now()
    report_file = open(
        report_every.format(report_name.get('fabu_data')), 'w', encoding='utf8')
    runner_add = HTMLTestRunner(
        stream=report_file,
        title=report_name.get('fabu_data'),
        description='配货项目测试报告')

    fabu_304(user_fabu)

    runner_add.run(cases)
Ejemplo n.º 4
0
def run_shenqingtihuo():

    path = cases_path.get('shenqingtihuo')

    dis = unittest.TestLoader()
    cases = dis.discover(path, pattern='*.py')  ##从指定的目录下,以.py结尾的文件中自动去寻找测试用例





    now = datetime.now()
    report_file = open(
        report_every.format(report_name.get('shenqingtihuo')), 'w', encoding='utf8')
    runner_shenqingtihuo = HTMLTestRunner(
        stream=report_file, title=report_name.get('shenqingtihuo'), description='配货项目测试报告')

    runner_shenqingtihuo.run(cases)
Ejemplo n.º 5
0
def input_detail_304(username):
    ##读取excel
    # datas=read_data(r'F:\autotest\peihuo\file\input_file\rukumingxi.xlsx')
    datas = read_data(excel_add_input)

    ##实例化,登录并进入相应界面
    process_front = Process_Front()
    process_front.process_login(username)
    process_front.into_shiwuruku()
    result = []
    for index, data in enumerate(datas):
        ##获得初始数据
        start_data = process_front.get_shiwuruku_count()

        ##录入
        remind_text = process_front.ruku_add_detail(*data)
        process_front.fresh()
        process_front.into_shiwuruku()

        ##获得录入后的数据
        end_data = process_front.get_shiwuruku_count()

        ##如果数字+1,录入成功,否则失败
        if start_data.get('num') + 1 == end_data.get('num'):
            print(index + 1, data[0], '录入成功', remind_text)
            historydata = HistoryData(username, '冷轧304卷', *data, 0)
            db.session.add(historydata)
            db.session.commit()
            one_result = (index + 1, data[0], '录入成功', remind_text)
        else:
            print(index + 1, data[0], '录入失败', remind_text)
            historydata = HistoryData(username, '冷轧304卷', *data, 1)
            db.session.add(historydata)
            db.session.commit()
            one_result = (index + 1, data[0], '录入失败', remind_text)
        result.append(one_result)

    ##以当前时间戳生成文件名,写入excel
    process_front.close()
    write_data(excel_every.format(report_name.get('add')), result,
               ('编号', '钢卷号', '结果', '提示信息'))
Ejemplo n.º 6
0
def fabu_304(username):
    ##读取excel
    datas = read_data(excel_fabu_input)

    ##实例化
    process_front=Process_Front()
    process_front.process_login(username)
    process_front.into_shangpinshangjia()

    ##判断商品上架界面数据是否足够,不够就自己录入补足
    shangpinshangjia_count=int(process_front.get_table_count())
    if len(datas)>shangpinshangjia_count:
        value=len(datas)-shangpinshangjia_count
        for i in range(value):
            process_front.into_shiwuruku()
            process_front.ruku_add_detail(stockCode='{}{}'.format(username,datetime.datetime.now().strftime('%Y%m%d%H%M%S')))
            process_front.fresh()

        ##全部申请入库
        process_front.fresh()
        process_front.into_shiwuruku()
        process_front.shiwuruku_apply()

    ##进入商品上架
    process_front.fresh()
    process_front.into_shangpinshangjia()
    result=[]
    for index,data in enumerate(datas):
        ##获得初始数据,表格第一条数据以及数据总数
        start_count=int(process_front.get_table_count())
        print('第{}次,初始数据{}'.format(index,start_count))
        tr=process_front.get_table_trs()[0]
        data_detail={
            'goodsname':tr.find('td',attrs={'name':'goodsName'}).text,
            'stockcode': tr.find('td', attrs={'name': 'stockCode'}).text,
            'goodsid': tr.find('td', attrs={'name': 'goodsId'}).text,
            'factoryname': tr.find('td', attrs={'name': 'factoryName'}).text,
            'weight': tr.find('td', attrs={'name': 'weightAvlb'}).text,
            'factoryid': tr.find('td', attrs={'name': 'factoryId'}).text,
            'material': tr.find('td', attrs={'name': '1'}).text,
            'thickness': tr.find('td', attrs={'name': '2'}).text,
            'standard_width': tr.find('td', attrs={'name': '3'}).text,
            'format': tr.find('td', attrs={'name': '4'}).text,
            'width': tr.find('td', attrs={'name': '5'}).text,
            'edge': tr.find('td', attrs={'name': '6'}).text,
            'level': tr.find('td', attrs={'name': '7'}).text,
            'standard_thickness': tr.find('td', attrs={'name': '8'}).text,
            'warehouse': tr.find('td', attrs={'name': 'warehouseName'}).text,
            'stocktype': tr.find('td', attrs={'name': 'stockType'}).text,
            'issueid': tr.find('td', attrs={'name': 'issueId'}).text,
            'applyid': tr.find('td', attrs={'name': 'applyId'}).text,
            'stockid': tr.find('td', attrs={'name': 'stockId'}).text,
        }
        text=process_front.fabu(premium=data[2],contract=data[0],date_valid=True if data[1]=='1' else False)
        process_front.fresh()
        process_front.into_shangpinshangjia()
        end_count=int(process_front.get_table_count())
        print('第{}次,结束数据{}'.format(index, end_count))


        if start_count-end_count==1:
            ##发布成功
            fabu=Fabu(
                username=username,
                goodsid=data_detail.get('goodsname'),
                stockCode=data_detail.get('stockcode'),
                factoryname=data_detail.get('factoryname'),
                weight=data_detail.get('weight'),
                material=data_detail.get('material'),
                standard_thickness=data_detail.get('standard_thickness'),
                standard_width=data_detail.get('standard_width'),
                format=data_detail.get('format'),
                width=data_detail.get('width'),
                edge=data_detail.get('edge'),
                level=data_detail.get('level'),
                thickness=data_detail.get('thickness'),
                warehouse=data_detail.get('warehouse'),
                applyid=data_detail.get('applyid'),
                stockid=data_detail.get('stockid'),
                status=0,
                contract=data[0],
                invalidtime=datetime.datetime.today().strftime('%Y-%m-%d') if data[1]=='1' else '',
                premium=str(int(float(data[2])*1000)),
            )
            ##加入数据库
            db.session.add(fabu)
            db.session.commit()
            ##excel写入内容
            result_one=[index+1,data[0],data[1],data[2],'发布成功',text]
            result.append(result_one)

        else:
            ##发布失败
            fabu = Fabu(
                username=username,
                goodsid=data_detail.get('goodsname'),
                stockCode=data_detail.get('stockcode'),
                factoryname=data_detail.get('factoryname'),
                weight=data_detail.get('weight'),
                material=data_detail.get('material'),
                standard_thickness=data_detail.get('standard_thickness'),
                standard_width=data_detail.get('standard_width'),
                format=data_detail.get('format'),
                width=data_detail.get('width'),
                edge=data_detail.get('edge'),
                level=data_detail.get('level'),
                thickness=data_detail.get('thickness'),
                warehouse=data_detail.get('warehouse'),
                applyid=data_detail.get('applyid'),
                stockid=data_detail.get('stockid'),
                status=1,
                contract=data[0],
                invalidtime=datetime.datetime.today().strftime('%Y-%m-%d') if data[1]=='1' else '',
                premium=data[2],
            )
            ##加入数据库
            db.session.add(fabu)
            db.session.commit()
            ##excel写入内容
            result_one = [index+1, data[0],data[1],data[2],'发布失败', text]
            result.append(result_one)
    ##关闭网页,将结果写入excel
    process_front.close()
    now=datetime.datetime.now().strftime('%Y%m%d%H%M%S')
    write_data(excel_every.format(report_name.get('fabu')),result,('编号','合约名称','日期是否有效','升贴水','结果','提示信息'))