test_ZCCreate.py 5.61 KB
# -*- coding: utf-8 -*-

# @Time    : 2021/8/6 17:49
# @Author  : Ljq
# @File    : test_ZCCreate.py
# @Software: PyCharm

"""
整车进门但创建测试
"""

import json
import unittest
from commons.scripts.readConf import rC
from commons.api import zcApi as zcA
from commons.api.entranceFeeBillList import entranceFeeBillList as eFBL
import time,random
from commons.MySession import sessionSy
session = sessionSy

class test_ZCCreate(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")

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

    def test_creZC(self):
        """整车-整车创建:按接车员名称信息查询接车员"""
        """整车-整车创建:获取车型接口调用测试"""
        # 依赖数据
        plate = "川A12323"
        productState = "1"
        trailerNumber = plate

        # 获取车型
        carType = zcA.get_carType(session=session,host=self.gatewayHost)
        print(carType.text)
        print(carType.json()["data"][0])
        carTypeCode = carType.json()["data"][0]["code"]
        carTypeId = carType.json()["data"][0]["id"]
        carTypeName = carType.json()["data"][0]["carTypeName"]
        carTypeWeight = carType.json()["data"][0]["weight"]

        # 获取商品
        categoryByCondition = zcA.get_listCategoryByCondition(session=session,host=self.gatewayHost)
        print(categoryByCondition.json())
        cateId = categoryByCondition.json()["data"][0]["id"]
        productId = categoryByCondition.json()["data"][0]["id"]
        productName = categoryByCondition.json()["data"][0]["name"]
        productCode = categoryByCondition.json()["data"][0]["keycode"]

        # 获取接车员
        listByExample = zcA.get_listByExample(session=session,host=self.gatewayHost)
        print(listByExample.json())
        inGreeterId = listByExample.json()["data"][0]["id"]
        inGreeterName = listByExample.json()["data"][0]["realName"]

        # 获取交易类型
        transactionType = zcA.query_transactionType(session=session,host=self.gatewayHost)
        print(transactionType.json())
        tradeType = transactionType.json()["rows"][0]["code"]
        tradeTypeId = transactionType.json()["rows"][0]["id"]
        tradeTypeName = transactionType.json()["rows"][0]["name"]

        # 获取货物标签
        goodsTag = zcA.get_goodsTag(session=session,host=self.gatewayHost)
        print(goodsTag.json())
        goodsTagId = goodsTag.json()["data"][0]["id"]

        # 产地信息获取
        address = zcA.get_address(session=session,host=self.gatewayHost)
        print(address.json())
        originId = address.json()["data"][0]["id"]
        origin = address.json()["data"][0]["name"]
        originCode = address.json()["data"][0]["cityCode"]

        # 查询部门信息
        depRes = zcA.get_dep(session=session,host=self.gatewayHost)
        print(depRes.json())
        feeDepId = depRes.json()["data"][0]["id"]
        feeDepName = depRes.json()["data"][0]["name"]

        # 获取证明类型
        proveType = zcA.get_proveType(session=session,host=self.gatewayHost)
        print(proveType.json())
        proveTypeCode = proveType.json()["data"][0]["id"]
        proveTypeName = proveType.json()["data"][0]["name"]

        # 获取防重token
        duplicateTokenRes = zcA.get_duplicateToken(session=session,host=self.gatewayHost)
        print(duplicateTokenRes.json())
        duplicateToken = duplicateTokenRes.json()["data"]

        # 重量信息准备
        grossWeight = random.randint(carTypeWeight, carTypeWeight + 100)
        tareWeight = carTypeWeight
        weighmanRecord = {"grossWeight": None, "grossWeightDate": "", "newWeight": None, "tareWeight": None,
                          "tareWeightDate": None, "weighImgs": []}
        weighmanRecord["grossWeight"] = grossWeight
        weighmanRecord["tareWeight"] = carTypeWeight
        weighmanRecord["newWeight"] = grossWeight - carTypeWeight
        weighmanRecord["grossWeightDate"] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())

        # 创建进门单
        cre_res = zcA.create_wholeCarWeighSave(session=session,host=self.gatewayHost, duplicateToken=duplicateToken,
                                               carTypeCode=carTypeCode, carTypeId=carTypeId,
                                               carTypeName=carTypeName, carTypeWeight=carTypeWeight, plate=plate,
                                               productId=productId, productName=productName,
                                               proveTypeCode=proveTypeCode,
                                               proveTypeName=proveTypeName, trailerNumber=trailerNumber,
                                               depName=feeDepName,
                                               cateId=cateId, originId=originId, origin=origin, originCode=originCode,
                                               tradeType=tradeType, tradeTypeName=tradeTypeName,
                                               productState=productState,
                                               tradeTypeId=tradeTypeId, goodsTagId=goodsTagId, inGreeterId=inGreeterId,
                                               inGreeterName=inGreeterName, dep=feeDepId, weighmanRecord=weighmanRecord)
        print(cre_res.json())
        assert cre_res.json()["code"] == "200","创建整车进门单失败"
        assert "data" in cre_res.text,"创建整车进门单失败"