class Test_Apply_One(unittest.TestCase):
    """申请入库一条数据"""

    # username='******'

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

        ##获得初始数据
        self.process_front.into_shiwuruku()
        self.start_shiwuruku = self.process_front.get_shiwuruku_count().get(
            'num')
        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.into_shiwuruku()
        self.process_front.ruku_add_detail()
        self.process_front.fresh()
        self.process_front.into_shiwuruku()
        self.process_front.shiwuruku_apply(all=False)

        ##获取各个界面操作后的数据
        self.process_front.into_shiwuruku()
        self.end_shiwuruku = self.process_front.get_shiwuruku_count().get(
            'num')
        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(int(self.start_shiwuruku), int(self.end_shiwuruku),
                         '实物入库界面')
        self.assertEqual(
            int(self.start_rukushenqingchaxun) + 1,
            int(self.end_rukushenqingchaxun),
            '入库申请查询界面,开始数据{},结束数据{}'.format(self.start_rukushenqingchaxun,
                                            self.end_rukushenqingchaxun))
        self.assertEqual(
            int(self.start_shangpinshangjia) + 1,
            int(self.end_shangpinshangjia),
            '商品上架界面,开始数据{},结束数据{}'.format(self.start_shangpinshangjia,
                                          self.end_shangpinshangjia))

    def tearDown(self):
        self.process_front.close()
Beispiel #2
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,
               ('编号', '钢卷号', '结果', '提示信息'))