'''
@Project ：gukeyitihua
@File    ：1.py
@IDE     ：PyCharm
@Author  ：何凯
@Date    ：2023/3/12 10:35
'''


import os
import logging
import allure
import pytest as pytest
from ddt import ddt, file_data

from page.GuKeYiTiHua.Public.common import CommonElement
from unit.public.DataDic import DataDic
from component.GuKeYiTiHua.Transfer.transfer_out import TransferOut
from component.GuKeYiTiHua.StorageManage.StorageOut.storage_out_integration import StorageOut
from component.GuKeYiTiHua.StorageManage.StorageOut.warehouse_check import WarehouseCheck
from component.GuKeYiTiHua.StorageManage.StorageOut.warehouse_delivery import WarehouseDelivery
from component.GuKeYiTiHua.StorageManage.StorageOut.warehouse_pick import WarehousePick
log = logging.getLogger(__name__)

@pytest.mark.incremental
@ddt
class TestBoundOrder(object):
    def setup_class(self):
        self.dd = DataDic()
        self.sr = TransferOut()
        self.so = StorageOut()
        self.wd = WarehouseDelivery()
        self.wp = WarehousePick()
        self.wc = WarehouseCheck()
        self.common = CommonElement()

    @allure.feature('出库')
    @allure.story('调拨出库单')
    @allure.title('调拨出库单创建')
    # @pytest.mark.skip(reason='调试通过')
    @allure.description('选择公司->选择业务员->选择调拨出库仓->选择调拨入库仓->保存->添加商品->输入数量->提交')
    @pytest.mark.transfer
    @pytest.mark.run(order=10)
    @file_data('{}/data/transferTestData.yaml'.format(os.getcwd()))
    def test_Outboundorder(self, **kwargs):
        log.info(kwargs)
        self.dd.set_value('test_data_info', kwargs)
        goods = kwargs['goods']
        #创建调拨出库单
        self.sr.open_menu_transfer_out()
        self.sr.transfer_out_code_create()
        transfer_out_code = self.dd.get_value('transfer_out_code')
        #审核
        self.sr.transfer_out_code_transact(transfer_out_code)
        self.common.close_tap()
        #库存管理-发货-拣货-复核
        transfer_out_code = self.dd.get_value('transfer_out_code')
        self.so.storage_out_integration(transfer_out_code, goods)


