test_ZC.py
5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# -*- coding: utf-8 -*-
# @Time : 2021/7/28 11:15
# @Author : Ljq
# @File : test_ZC.py
# @Software: PyCharm
"""
整车进门测试用例
"""
import json
import unittest
from commons.scripts.readConf import rC
from commons.api import zcApi as zcA
from commons.api import entranceFeeBillList as eFBL
import time,random
class test_demo(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
# @unittest.skip
def test_get_carType(self):
"""整车-整车创建:获取车型接口调用测试"""
# 依赖数据
plate = "川A12323"
productState = "1"
trailerNumber = plate
# 获取车型
carType = zcA.get_carType(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(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(host=self.gatewayHost)
print(listByExample.json())
inGreeterId = listByExample.json()["data"][0]["id"]
inGreeterName = listByExample.json()["data"][0]["realName"]
# 获取交易类型
transactionType = zcA.query_transactionType(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(host=self.gatewayHost)
print(goodsTag.json())
goodsTagId = goodsTag.json()["data"][0]["id"]
# 产地信息获取
address = zcA.get_address(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(host=self.gatewayHost)
print(depRes.json())
feeDepId = depRes.json()["data"][0]["id"]
feeDepName = depRes.json()["data"][0]["name"]
# 获取证明类型
proveType = zcA.get_proveType(host=self.gatewayHost)
print(proveType.json())
proveTypeCode = proveType.json()["data"][0]["id"]
proveTypeName = proveType.json()["data"][0]["name"]
# 获取防重token
duplicateTokenRes = zcA.get_duplicateToken(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(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())
def test_cre(self):
"""调用方法1"""
cre_res = zcA.create_jmsf(host=self.gatewayHost,carTypeName="板车",plate="川B00001",keyword="雪莲果",
userName="ty_test",transactionName="沈阳2号",newWeight=20,
depName="接车部",goodsTagName="货物标签测试",proveName="绿色蔬菜")
print(cre_res.json())
number = cre_res.json()["data"]["number"]
aa = eFBL.do_payOrder(attrValue=number)
# cre_res = zcA.create_jmsf(host=self.gatewayHost,plate="川B00002",newWeight=20)
# print(cre_res.json())
# if __name__ == "__main__":
# unittest.main()
#