test_listPageOperation.py 8.26 KB
# -*- coding: utf-8 -*-

# @Time    : 2021/8/11 15:25
# @Author  : Ljq
# @File    : test_listPageOperation.py
# @Software: PyCharm

"""

"""

import unittest
from commons.scripts.readConf import rC
from commons.api.sy import zcApi as zcA, hpApi, sjApi
from commons.api.sy.entranceFeeBillList import operationDoUpdate as oDUp, operationDoInvalid as oDI, \
    entranceFeeBillList as eFBL, operationDoAmend as oDA, operationDoCorrect as oDC, operationDoUndo as oDU, \
    operationDoFreeze as oDF, operationUnfreeze as eOp
import random

from commons.MySession import sessionHeb
session = sessionHeb

class test_listPage(unittest.TestCase):
    """哈尔滨市场-进门单列表:进门但操作测试测试"""
    def setUp(self) -> None:
        pass

    def tearDown(self) -> None:
        pass

    @classmethod
    def setUpClass(cls) -> None:
        cls.gatewayHost = rC.returnOptionsItems("host", "gatewayHost")
        cls.jmsfHost = rC.returnOptionsItems("host", "jmsfHost")
        cls.ic = rC.returnOptionsItems("testInfo", "hd_cardNumRe_01")

    @classmethod
    def tearDownClass(cls) -> None:
        pass

    def test_viewOrder(self):
        """进门单列表-操作:查看进门单详情测试"""
        res = zcA.create_jmsf(session=session,host=self.gatewayHost)
        orderId = res.json()["data"]["id"]
        number = res.json()["data"]["number"]
        res = eFBL.get_orderView(session=session,host=self.jmsfHost,orderId=orderId)
        assert str(number) in res.text,"获取订单详情查询失败"

    def test_doPayZC(self):
        """进门单列表-操作:整车进门交费测试"""
        plate = f"川A{random.randint(10000,99999)}"
        goods = "雪莲果"
        cre_res = zcA.create_jmsf(session=session,host=self.gatewayHost,plate=plate,keyword=goods)
        print(cre_res.json())
        number = cre_res.json()["data"]["number"]
        res_pay = eFBL.do_payOrder(session=session,host=self.jmsfHost,attrValue=number,ic=self.ic)
        assert res_pay.json()["code"]=="200","缴费失败"
        assert res_pay.json()["message"] == "OK", "缴费失败"

    def test_updateOrder(self):
        """进门单列表-操作:修改进门单测试"""
        plate = f"川A{random.randint(10000,99999)}"
        goods = "雪莲果"
        cre_res = zcA.create_jmsf(session=session,host=self.gatewayHost,plate=plate,keyword=goods)
        print(cre_res.json())
        number = cre_res.json()["data"]["number"]
        res_pay = oDUp.do_updateOrder(session=session,host=self.jmsfHost,attrValue=number)
        assert res_pay.json()["success"]==True,"修改进门单失败"
        assert res_pay.json()["message"] == "修改保存成功", "修改进门单失败"

    def test_doPaySJ(self):
        """进门单列表-操作:散件进门交费测试"""
        plate = f"川A{random.randint(10000,99999)}"
        goods = "雪莲果"
        cre_res = sjApi.create_sj(session=session, host=self.gatewayHost, plate=plate, keyword=goods)
        print(cre_res.json())
        number = cre_res.json()["data"]["number"]
        res_pay = eFBL.do_payOrder(session=session,host=self.jmsfHost,attrValue=number,ic=self.ic)
        assert res_pay.json()["code"]=="200","缴费失败"
        assert res_pay.json()["message"] == "OK", "缴费失败"

    def test_unfreezeOrderInfo(self):
        """进门单列表-操作:散件进门交费测试"""
        plate = f"川A{random.randint(10000,99999)}"
        goods = "雪莲果"
        cre_res = zcA.create_jmsf(session=session,host=self.gatewayHost,plate=plate,keyword=goods)
        print(cre_res.json())
        number = cre_res.json()["data"]["number"]
        res_pay = oDF.do_freezeOrder(session=session,host=self.jmsfHost,attrValue=number,ic=self.ic)
        assert res_pay.json()["code"]=="200","缴费失败"
        assert res_pay.json()["message"] == "OK", "缴费失败"
        res,tareWeight = hpApi.do_backSkinWeighSave(session=session, host=self.gatewayHost, number=number)
        assert res.json()["code"]=="200","回皮失败"
        assert "data" in res.text,"回皮失败"
        resListPage = eFBL.listPage(session=session,host=self.jmsfHost,attrValue=number)
        print(resListPage.json())
        assert resListPage.json()["rows"][0]["number"] == number,"按照收费单号查询失败"
        assert resListPage.json()["rows"][0]["tareWeight"] == tareWeight,"按照收费单号查询失败"


    def test_freezeOrder(self):
        """进门单列表-操作:整车进门冻结测试"""
        plate = f"川A{random.randint(10000,99999)}"
        goods = "雪莲果"
        cre_res = zcA.create_jmsf(session=session,host=self.gatewayHost,plate=plate,keyword=goods)
        print(cre_res.json())
        number = cre_res.json()["data"]["number"]
        res_pay = oDF.do_freezeOrder(session=session,host=self.jmsfHost,attrValue=number,ic=self.ic)
        assert res_pay.json()["code"]=="200","冻结失败"
        assert res_pay.json()["message"] == "OK", "冻结失败"

    def test_unfreezeOrder(self):
        """进门单列表-操作:整车进门解冻测试"""
        plate = f"川A{random.randint(10000,99999)}"
        goods = "雪莲果"
        cre_res = zcA.create_jmsf(session=session,host=self.gatewayHost,plate=plate,keyword=goods)
        print(cre_res.json())
        number = cre_res.json()["data"]["number"]
        oDF.do_freezeOrder(session=session,host=self.jmsfHost,attrValue=number,ic=self.ic)
        res_unfreezeOrder = eOp.do_unfreezeOrder(session=session,host=self.jmsfHost,attrValue=number)
        assert res_unfreezeOrder.json()["code"]=="200","解冻失败"
        assert res_unfreezeOrder.json()["message"] == "OK", "解冻失败"

    def test_invalidOrder(self):
        """进门单列表-操作:整车进门作废测试"""
        plate = f"川A{random.randint(10000,99999)}"
        cre_res = zcA.create_jmsf(session=session,host=self.gatewayHost,plate=plate)
        print(cre_res.json())
        number = cre_res.json()["data"]["number"]
        res_unfreezeOrder = oDI.do_invalidOrder(session=session,host=self.jmsfHost,attrValue=number)
        assert res_unfreezeOrder.json()["number"]==number,"作废测试失败"
        assert res_unfreezeOrder.json()["message"] == "作废成功!", "作废测试失败"

    def test_correctOrder(self):
        """进门单列表-操作:整车进门更正测试"""
        plate = f"川A{random.randint(10000,99999)}"
        cre_res = zcA.create_jmsf(session=session,host=self.gatewayHost,plate=plate)
        print(cre_res.json())
        number = cre_res.json()["data"]["number"]
        res_unfreezeOrder,totalAmount = oDC.do_correctOrder(session=session,host=self.jmsfHost,attrValue=number)
        assert res_unfreezeOrder.json()["success"]==True,"更正测试失败"
        assert res_unfreezeOrder.json()["msg"] == "操作成功", "更正测试失败"
        resListPage = eFBL.listPage(session=session,host=self.jmsfHost,attrValue=number)
        print(resListPage.json())
        assert resListPage.json()["rows"][0]["number"] == number,"按照收费单号查询失败"
        assert resListPage.json()["rows"][0]["$_totalPrice"] == totalAmount,"更正后订单界错误与预期金额不一致"

    def test_amendOrder(self):
        """进门单列表-操作:整车进门修正测试"""
        plate = f"川A{random.randint(10000,99999)}"
        cre_res = zcA.create_jmsf(session=session,host=self.gatewayHost,plate=plate)
        print(cre_res.json())
        number = cre_res.json()["data"]["number"]
        res_unfreezeOrder = oDA.do_amendOrder(session=session,host=self.jmsfHost,attrValue=number)
        assert res_unfreezeOrder.json()["success"]==True,"修正操作失败"
        assert res_unfreezeOrder.json()["message"] == "操作成功", "修正操作失败"

    def test_undoOrder(self):
        """进门单列表-操作:整车进门退款测试"""
        plate = f"川A{random.randint(10000,99999)}"
        goods = "雪莲果"
        cre_res = zcA.create_jmsf(session=session,host=self.gatewayHost,plate=plate,keyword=goods)
        number = cre_res.json()["data"]["number"]
        res_pay = eFBL.do_payOrder(session=session,host=self.jmsfHost,attrValue=number,ic=self.ic)
        res_undo = oDU.do_undoOrder(session=session,host=self.jmsfHost,attrValue=number)
        assert res_undo.json()["code"] == "200","退款失败"
        assert res_undo.json()["message"] == "OK","退款失败"