test_batch.py
6.43 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
# -*- coding: utf-8 -*-
# @Time : 2021/9/10 10:17
# @Author : Ljq
# @File : test_batch.py
# @Software: PyCharm
"""
杭果市场-结算管理-批号管理
"""
from commons.MySession import sessionHg as session
from commons.api.hg.CheckIn import CheckIn
from commons.api.hg.settlement import batch
from commons.scripts.readConf import rC
import unittest,random
class test_batch(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", "hg_cardNumRe_01")
@classmethod
def tearDownClass(cls) -> None:
pass
def test_searchState_1(self):
"""
批号管理--查询--输入【在售】状态的完整批号,查询出该批号下的相关数据
"""
# 创建初始数据
resBatchCode = CheckIn.create_registerRecord(session=session, host=self.gatewayHost,ic=self.ic)
self.batchCode = resBatchCode.json()["data"]["batchCode"]
# 执行查询
print("test_searchState_1 --> self.batchCode:",self.batchCode)
resSearchState = batch.batchCodeQuery(session=session,host=self.gatewayHost,batchCode=self.batchCode)
print(resSearchState.json())
assert resSearchState.json()["code"] == "200","在售状态的登记单查询失败"
assert resSearchState.json()["state"] == 1,"在售状态的登记单查询失败"
assert resSearchState.json()["data"]["state"] == 1, "在售状态的登记单查询失败"
assert resSearchState.json()["data"]["batchCode"] == self.batchCode, "在售状态的登记单查询失败"
def test_searchState_2(self):
"""
批号管理--查询--输入【关闭】状态的完整批号,查询出该批号下的相关数据
"""
# 创建初始数据
resBatchCode = CheckIn.create_registerRecord(session=session, host=self.gatewayHost,ic=self.ic)
self.batchCode = resBatchCode.json()["data"]["batchCode"]
print("test_searchState_1 --> self.batchCode:", self.batchCode)
# 将批号关闭
resChange = batch.changeBatchCodeState(session=session,host=self.gatewayHost,batchCode=self.batchCode)
assert resChange.json()["message"] == "success","批号关闭成功"
# 执行查询
resSearchState = batch.batchCodeQuery(session=session,host=self.gatewayHost,batchCode=self.batchCode)
print(resSearchState.json())
assert resSearchState.json()["code"] == "200","在售状态的登记单查询失败"
assert resSearchState.json()["state"] == 2,"在售状态的登记单查询失败"
assert resSearchState.json()["data"]["state"] == 2, "在售状态的登记单查询失败"
assert resSearchState.json()["data"]["batchCode"] == self.batchCode, "在售状态的登记单查询失败"
def test_batchDetails(self):
"""
批号管理--列表--【列表】中数据显示正确
"""
# 创建初始数据
goodsName="西瓜"
weight = random.randint(50,100)
print("weight",weight)
resBatchCode = CheckIn.create_registerRecord(session=session, host=self.gatewayHost,ic=self.ic,goodsName=goodsName,
weight=weight)
self.batchCode = resBatchCode.json()["data"]["batchCode"]
print("test_searchState_1 --> self.batchCode:", self.batchCode)
# 执行查询
resSearchState = batch.batchCodeQuery(session=session,host=self.gatewayHost,batchCode=self.batchCode)
print(resSearchState.json())
assert resSearchState.json()["code"] == "200","查询状态码返回错误"
assert resSearchState.json()["data"]["batchCode"] == self.batchCode, "查询获得订单与实际订单不一致"
assert resSearchState.json()["data"]["registerDetail"][0]["categoryName"] == goodsName, "批号的商品信息与创建时不一致"
assert resSearchState.json()["data"]["registerDetail"][0]["weight"] == weight, "批号的重量信息与创建时不一致"
def test_changeState_1(self):
"""
批号管理--恢复交款--“关闭”状态的批号,可【恢复交款】成功
"""
# 创建初始数据
resBatchCode = CheckIn.create_registerRecord(session=session, host=self.gatewayHost,ic=self.ic)
self.batchCode = resBatchCode.json()["data"]["batchCode"]
print("test_searchState_1 --> self.batchCode:", self.batchCode)
# 将批号关闭
resChange = batch.changeBatchCodeState(session=session,host=self.gatewayHost,batchCode=self.batchCode,state=2)
assert resChange.json()["message"] == "success","批号关闭成功"
resChange = batch.changeBatchCodeState(session=session,host=self.gatewayHost,batchCode=self.batchCode,state=1)
assert resChange.json()["message"] == "success","批号关闭成功"
# 执行查询
resSearchState = batch.batchCodeQuery(session=session,host=self.gatewayHost,batchCode=self.batchCode)
print(resSearchState.json())
assert resSearchState.json()["data"]["state"] == 1, "在售状态的登记单查询失败"
assert resSearchState.json()["data"]["batchCode"] == self.batchCode, "在售状态的登记单查询失败"
def test_changeState_2(self):
"""
批号管理--恢复交款--“在售”状态的批号,可【停止交款】成功
"""
# 创建初始数据
resBatchCode = CheckIn.create_registerRecord(session=session, host=self.gatewayHost,ic=self.ic)
self.batchCode = resBatchCode.json()["data"]["batchCode"]
print("test_searchState_1 --> self.batchCode:", self.batchCode)
# 将批号关闭
resChange = batch.changeBatchCodeState(session=session,host=self.gatewayHost,batchCode=self.batchCode,state=2)
assert resChange.json()["message"] == "success","批号关闭成功"
# 执行查询
resSearchState = batch.batchCodeQuery(session=session,host=self.gatewayHost,batchCode=self.batchCode)
print(resSearchState.json())
assert resSearchState.json()["data"]["state"] == 2, "在售状态的登记单查询失败"
assert resSearchState.json()["data"]["batchCode"] == self.batchCode, "在售状态的登记单查询失败"