test_searchByAttrName.py
6.93 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
# -*- coding: utf-8 -*-
# @Time : 2021/8/10 15:32
# @Author : Ljq
# @File : test_searchByAttrName.py
# @Software: PyCharm
"""
进门单列表查询
"""
import json
import unittest
from commons.scripts.readConf import rC
from commons.api import zcApi as zcA
from commons import ConfigDB as CoDB
from commons.MySession import my
from commons.api.entranceFeeBillList import entranceFeeBillList as eFBL
import time,random
from commons.MySession import sessionSy
session = sessionSy
class test_listPage(unittest.TestCase):
"""沈阳市场-进门单列表:attr进门单属性查询测试"""
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", "sy_cardNumRe_01")
@classmethod
def tearDownClass(cls) -> None:
pass
def test_searchByNumber(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"]
resListPage = eFBL.listPage(session=session,host=self.jmsfHost,attrValue=number)
print(resListPage.json())
assert resListPage.json()["rows"][0]["number"] == number,"按照收费单号查询失败"
assert len(resListPage.json()["rows"]) == 1,"按照收费单号查询失败"
def test_searchByPlate(self):
"""进门单列表-查询:车牌号查询测试"""
plate = f"川A{random.randint(10000, 99999)}"
goods = "雪莲果"
cre_res = zcA.create_jmsf(session=session,host=self.gatewayHost,plate=plate,keyword=goods)
resListPage = eFBL.listPage(session=session,host=self.jmsfHost,attrName="车号",attrValue=plate)
print(resListPage.json())
assert resListPage.json()["rows"][0]["plate"] == plate,"按照车牌号查询失败"
def test_searchByGoods(self):
"""进门单列表-查询:商品查询测试"""
goods = "圣女果"
cre_res = zcA.create_jmsf(session=session,host=self.gatewayHost,keyword=goods)
resListPage = eFBL.listPage(session=session,host=self.jmsfHost,attrName="商品",attrValue=goods)
print(resListPage.json())
assert resListPage.json()["rows"][0]["productName"] == goods,"按照商品查询失败"
def test_searchByTollman(self):
"""进门单列表-查询:收费员查询测试"""
plate = f"川A{random.randint(10000, 99999)}"
goods = "雪莲果"
userName = "ty_test"
cre_res = zcA.create_jmsf(session=session,host=self.gatewayHost,plate=plate,keyword=goods,userName=userName)
number = cre_res.json()["data"]["number"]
# 进门单缴费
eFBL.do_payOrder(session=session,host=self.jmsfHost,attrValue=number)
payUser = session.userInfo["data"]["user"]["realName"]
resListPage = eFBL.listPage(session=session,host=self.jmsfHost,attrName="收费员",attrValue=payUser)
numberList = [i["number"] for i in resListPage.json()["rows"]]
numberStr = ",".join(numberList)
# 缴费状态验证
assert resListPage.json()["rows"][0]["status"] == "已缴费","收费状态错误"
# 查询结果验证
cashier_name = CoDB.mysql_selectAll(f'SELECT cashier_name FROM entrance_fee_bill WHERE number in ({numberStr})')
cashier_name_list = [i[0] for i in cashier_name]
assert cashier_name_list[0] == payUser, "按照收费员查询失败"
def test_searchByCname(self):
"""进门单列表-查询:客户名称查询测试"""
ic = self.ic
cName = eFBL.get_icCheck(session=session,host=self.jmsfHost,ic=ic).json()["data"]["aInfo"]["customerName"]
# 创建进门单
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"]
# 进门单缴费
eFBL.do_payOrder(session=session,host=self.jmsfHost,attrValue=number,ic=ic)
resListPage = eFBL.listPage(session=session,host=self.jmsfHost,attrName="客户姓名",attrValue=cName)
print(resListPage.json())
cNameList = list(set([i["customerName"] for i in resListPage.json()["rows"]]))
print(cNameList)
# 缴费状态验证
assert resListPage.json()["rows"][0]["status"] == "已缴费","按照客户姓名查询失败"
assert len(cNameList)==1,"按照客户姓名查询失败"
assert cName == cNameList[0], "按照客户姓名查询失败"
def test_searchByIc(self):
"""进门单列表-查询:客户卡号查询测试"""
ic = self.ic
# 创建进门单
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"]
eFBL.do_payOrder(session=session,host=self.jmsfHost,attrValue=number,ic=ic)
resListPage = eFBL.listPage(session=session,host=self.jmsfHost,attrName="客户卡号",attrValue=ic)
print(resListPage.json())
icList = list(set([i["ic"] for i in resListPage.json()["rows"]]))
print(icList)
# 缴费状态验证
assert resListPage.json()["rows"][0]["status"] == "已缴费","按照客户卡号查询失败"
assert len(icList)==1,"按照客户卡号查询失败"
assert ic == icList[0], "按照客户卡号查询失败"
def test_searchByPhone(self):
"""进门单列表-查询:手机号码询测试"""
ic = self.ic
cPhone = eFBL.get_icCheck(session=session,host=self.jmsfHost,ic=ic).json()["data"]["aInfo"]["customerContactsPhone"]
# 创建进门单并缴费
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"]
eFBL.do_payOrder(session=session,host=self.jmsfHost,attrValue=number,ic=ic)
# 查询进门单
resListPage = eFBL.listPage(session=session,host=self.jmsfHost,attrName="手机号码",attrValue=cPhone)
numberList = [i["number"] for i in resListPage.json()["rows"]]
numberStr = ",".join(numberList)
cPhoneFromDb = CoDB.mysql_selectAll(f'SELECT customer_phone FROM entrance_fee_bill WHERE number in ({numberStr});')
cPhoneList = list(set([i[0] for i in cPhoneFromDb]))
# 缴费状态验证
assert resListPage.json()["rows"][0]["status"] == "已缴费","按照客户姓名查询失败"
assert cPhone == cPhoneList[0], "按照客户姓名查询失败"