示例#1
0
class Test_Apply_All(unittest.TestCase):
    """申请入库多条数据"""

    # username='******'

    def setUp(self):
        self.process_front = Process_Front()
        self.process_front.process_login(user_add)

        ##获得初始数据
        self.process_front.into_rukushenqingchaxun()
        self.start_rukushenqingchaxun = self.process_front.get_table_count()
        self.process_front.fresh()
        self.process_front.into_shangpinshangjia()
        self.start_shangpinshangjia = self.process_front.get_table_count()

        ##全部入库申请
        self.process_front.fresh()
        self.process_front.into_shiwuruku()
        self.start_shiwuruku = self.process_front.get_shiwuruku_count().get(
            'num')
        self.process_front.shiwuruku_apply()

        ##获取各个界面操作后的数据
        self.process_front.fresh()
        self.process_front.into_shiwuruku()
        self.end_shiwuruku = self.process_front.get_shiwuruku_count().get(
            'num')
        self.process_front.fresh()
        self.process_front.into_rukushenqingchaxun()
        self.end_rukushenqingchaxun = self.process_front.get_table_count()
        self.process_front.fresh()
        self.process_front.into_shangpinshangjia()
        self.end_shangpinshangjia = self.process_front.get_table_count()

    def test_1(self):
        """各界面统计"""
        self.assertEqual(self.end_shiwuruku, 0, '实物入库界面')
        self.assertEqual(
            int(self.start_rukushenqingchaxun) + 1,
            int(self.end_rukushenqingchaxun),
            '入库申请查询界面,开始数据{},结束数据{}'.format(self.start_rukushenqingchaxun,
                                            self.end_rukushenqingchaxun))
        self.assertEqual(
            int(self.start_shangpinshangjia) + int(self.start_shiwuruku),
            int(self.end_shangpinshangjia),
            '商品上架界面,开始数据{},结束数据{}'.format(self.start_shangpinshangjia,
                                          self.end_shangpinshangjia))

    def tearDown(self):
        self.process_front.close()
class Test_Shenqingtihuo_Add_All(unittest.TestCase):
    """录入仓单用户全选数据申请入库"""
    def setUp(self):
        self.process_front = Process_Front()
        self.process_front.process_login(user_add)

        # 获得提货申请界面表格统计数据
        self.process_front.into_tihuoshenqing()
        self.start_num_tihuoshenqing = self.process_front.get_table_count()

        # 获得提货申请查询界面表格统计统计
        self.process_front.fresh()
        self.process_front.into_tihuoshenqingchaxun()
        self.start_num_tihuoshenqingchaxun = self.process_front.get_table_count(
        )

        # 申请一条数据入库
        self.process_front.fresh()
        self.process_front.into_tihuoshenqing()
        self.process_front.shenqingtihuo(one=False)

        # 获得提货申请界面表格统计数据
        self.process_front.fresh()
        self.process_front.into_tihuoshenqing()
        self.end_num_tihuoshenqing = self.process_front.get_table_count()

        # 获得提货申请查询界面表格统计统计
        self.process_front.fresh()
        self.process_front.into_tihuoshenqingchaxun()
        self.end_num_tihuoshenqingchaxun = self.process_front.get_table_count()

    def test_1(self):
        """两个界面数据验证"""
        if self.start_num_tihuoshenqing > 10:
            self.assertEqual(
                self.start_num_tihuoshenqing, self.end_num_tihuoshenqing + 10,
                '提货申请界面表格统计数据验证,初始数据:{},结束数据:{}'.format(
                    self.start_num_tihuoshenqing, self.end_num_tihuoshenqing))
        else:
            self.assertEqual(
                self.end_num_tihuoshenqing, 0,
                '提货申请界面表格统计数据验证,初始数据:{},结束数据:{}'.format(
                    self.start_num_tihuoshenqing, self.end_num_tihuoshenqing))
        self.assertEqual(
            self.start_num_tihuoshenqingchaxun,
            self.end_num_tihuoshenqingchaxun - 1,
            '提货申请查询界面表格统计数据验证,初始数据:{},结束数据:{}'.format(
                self.start_num_tihuoshenqingchaxun,
                self.end_num_tihuoshenqingchaxun))

    def tearDown(self):
        self.process_front.close()
示例#3
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,
               ('编号', '钢卷号', '结果', '提示信息'))
class Test_Shenqingtihuo_Add_one(unittest.TestCase):
    """录入仓单用户选择一条数据申请入库"""

    def setUp(self):
        self.process_front = Process_Front()
        self.process_front.process_login(user_shenqingruku_one)

        # 获得提货申请界面表格统计数据
        self.process_front.into_tihuoshenqing()
        self.start_num_tihuoshenqing = self.process_front.get_table_count()

        # 获得提货申请查询界面表格统计统计
        self.process_front.fresh()
        self.process_front.into_tihuoshenqingchaxun()
        self.start_num_tihuoshenqingchaxun = self.process_front.get_table_count()

        # 申请一条数据入库
        self.process_front.fresh()
        self.process_front.into_tihuoshenqing()
        self.process_front.shenqingtihuo()

        # 获得提货申请界面表格统计数据
        self.process_front.fresh()
        self.process_front.into_tihuoshenqing()
        self.end_num_tihuoshenqing = self.process_front.get_table_count()

        # 获得提货申请查询界面表格统计统计
        self.process_front.fresh()
        self.process_front.into_tihuoshenqingchaxun()
        self.end_num_tihuoshenqingchaxun = self.process_front.get_table_count()

    def test_1(self):
        """两个界面数据验证"""
        self.assertEqual(
            self.start_num_tihuoshenqing,
            self.end_num_tihuoshenqing + 1,
            '提货申请界面表格统计数据验证,开始数据{}.结束数据{}'.format(
                self.start_num_tihuoshenqing,
                self.end_num_tihuoshenqing))
        self.assertEqual(
            self.start_num_tihuoshenqingchaxun,
            self.end_num_tihuoshenqingchaxun - 1,
            '提货申请查询界面表格统计数据验证,开始数据{},结束数据{}'.format(
                self.start_num_tihuoshenqingchaxun,
                self.end_num_tihuoshenqingchaxun))

    def tearDown(self):
        self.process_front.close()
示例#5
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,('编号','合约名称','日期是否有效','升贴水','结果','提示信息'))