test_ZCBasic.py
7.58 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# -*- coding: utf-8 -*-
# @Time : 2021/8/6 16:29
# @Author : Ljq
# @File : test_ZCBasic.py
# @Software: PyCharm
"""
整车进门基础数据获取测试
"""
import json
import unittest
from commons.scripts.readConf import rC
from commons.api import zcApi as zcA
from commons.basic import getLookupList as gLL
from commons.MySession import sessionSy
session = sessionSy
class test_ZCBasic(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_getCar(self):
"""整车-整车创建:获取车型接口调用测试"""
# 获取车型
carType = zcA.get_carType(session=session,host=self.gatewayHost)
print(carType.text)
assert carType.json()["code"] == "200"
assert carType.json()["data"] != []
def test_getAllCategory(self):
"""整车-整车创建:获取测试商品信息测试"""
# 获取
# print(session.userInfo["data"]["user"]["firmCode"])
marketId = session.userInfo["data"]["user"]["firmId"]
resCategory = zcA.get_listCategoryByCondition(session=session,host=self.gatewayHost,marketId=marketId,keyword="")
print(resCategory.text)
assert resCategory.json()["code"] == "200","全商品查询失败"
assert resCategory.json()["data"] != [],"全商品查询失败,查询结果不应该为空"
def test_getOneCategory(self):
"""整车-整车创建:获取测试商品信息测试"""
# 获取
marketId = session.userInfo["data"]["user"]["firmId"]
resCategory = zcA.get_listCategoryByCondition(session=session,host=self.gatewayHost,marketId=marketId,keyword="火龙果")
print(resCategory.text)
nameList = [i["name"] for i in resCategory.json()["data"]]
assert resCategory.json()["code"] == "200"
for i in nameList:
assert "火龙果" in i,"指定条件查询失败,按照名称查询出商品错误"
def test_getAllExample(self):
"""整车-整车创建:接车员信息获取测试"""
# print(session.userInfo["data"]["user"]["departmentId"])
firmCode = session.userInfo["data"]["user"]["firmCode"]
departmentId = session.userInfo["data"]["user"]["departmentId"]
listByExample = zcA.get_listByExample(session=session,host=self.gatewayHost,firmCode=firmCode,departmentId=departmentId)
print(listByExample.json())
assert listByExample.json()["code"]=="200","接车员信息获取测试失败"
assert listByExample.json()["data"]!=[],"接车员信息获取测试失败"
def test_getOneExample(self):
"""整车-整车创建:按接车员名称信息查询接车员"""
# print(session.userInfo["data"]["user"]["departmentId"])
# firmCode = session.userInfo["data"]["user"]["firmCode"]
# departmentId = session.userInfo["data"]["user"]["departmentId"]
firmCode = session.userInfo["data"]["user"]["firmCode"]
firmId = session.userInfo["data"]["user"]["firmId"]
try:
res_config = gLL.get_config(session=session,host=self.gatewayHost, marketId=firmId)
departmentId = [i["value"] for i in res_config.json()["rows"] if i["name"] == "DepartmentId"][0]
except:
departmentId = None
keyword="测试"
listByExample = zcA.get_listByExample(session=session,host=self.gatewayHost,firmCode=firmCode,departmentId=departmentId,
keyword=keyword)
print(listByExample.json())
assert listByExample.json()["code"]=="200","按接车员名称信息查询接车员测试失败"
assert listByExample.json()["data"]!=[],"按接车员名称信息查询接车员测试失败"
def test_transactionType(self):
"""整车-整车创建:交易类型获取测试"""
transactionType = zcA.query_transactionType(session=session,host=self.gatewayHost)
print(transactionType.json())
assert transactionType.status_code==200,"交易类型信息获取测试失败"
assert transactionType.json()["rows"]!=[],"交易类型信息获取测试失败"
def test_getGoodsTag(self):
"""整车-整车创建:货物标签获取测试"""
goodsTag = zcA.get_goodsTag(session=session,host=self.gatewayHost)
print(goodsTag.json())
assert goodsTag.status_code==200,"货物标签信息获取测试失败"
assert goodsTag.json()["data"]!=[],"货物标签信息获取测试失败"
def test_getAllAddress(self):
"""整车-整车创建:按照省份查询产地"""
province = "四川省"
address = zcA.get_address(session=session,host=self.gatewayHost,province=province)
print(address.json())
assert address.json()["code"] == "200","按照省份查询产地信息获取测试失败"
mergerNameList = [i["mergerName"] for i in address.json()["data"] if province not in i["mergerName"]]
assert mergerNameList == [],"按照省份查询产地信息获取测试失败"
def test_getOneAddress(self):
"""整车-整车创建:按照省份查询产地"""
province = "四川省"
city = "成都市"
area = "锦江区"
address = zcA.get_address(session=session,host=self.gatewayHost,province=province,city=city,area=area)
print(address.json())
assert address.json()["code"]=="200","详细产地信息查询失败"
assert len(address.json()["data"])==1,"详细产地信息查询只能查询出一个结果,查询结果超过一个测试失败"
assert address.json()["data"][0]["mergerName"] == "四川省,成都市,锦江区","根据省市区查询插地信息查询失败"
def test_getAllDep(self):
"""整车-整车创建:接车部门信息获取"""
depRes = zcA.get_dep(session=session,host=self.gatewayHost)
print(depRes.json())
assert depRes.json()["code"]=="200","接车部门信息获取测试失败"
assert depRes.json()["data"] != [], "接车部门信息获取测试失败"
def test_getOneDep(self):
"""整车-整车创建:查询指定接车部门信息"""
keyword="水果部"
depRes = zcA.get_dep(session=session,host=self.gatewayHost,keyword=keyword)
print(depRes.json())
assert depRes.json()["code"]=="200","查询指定接车部门信息获取测试失败"
assert len(depRes.json()["data"]) == 1, "查询指定接车部门信息获取测试失败"
assert depRes.json()["data"][0]["name"] == keyword,"查询指定接车部门信息获取测试失败"
def test_getProveType(self):
"""整车-整车创建:证明类型信息获取"""
proveType = zcA.get_proveType(session=session,host=self.gatewayHost)
print(proveType.json())
assert proveType.json()["code"]=="200","证明类型信息获取测试失败"
assert proveType.json()["data"] != [], "证明类型信息获取测试失败"
def test_getDuplicateToken(self):
"""整车-整车创建:获取防重复token"""
duplicateTokenRes = zcA.get_duplicateToken(session=session,host=self.gatewayHost)
print(duplicateTokenRes.json())
assert duplicateTokenRes.json()["code"]=="200","获取防重复token测试失败"
assert duplicateTokenRes.json()["data"].isalnum(), "获取防重复token测试失败"