Commit f6e00746446b59f710cd15eb53f3fd35fd8e2982
1 parent
4672200f
入库测试用例添加
Showing
17 changed files
with
912 additions
and
31 deletions
commons/ConfigDB.py
commons/api/cardStock.py
0 → 100644
1 | +#coding=utf-8 | |
2 | + | |
3 | +# @Time : 2021/7/16 14:09 | |
4 | +# @Author : Ljq | |
5 | +# @File : cardStock.py | |
6 | +# @Software: PyCharm | |
7 | + | |
8 | + | |
9 | +""" | |
10 | + 卡片库存接口 | |
11 | +""" | |
12 | + | |
13 | +import requests | |
14 | +import json | |
15 | +from commons.readConf import readConfig | |
16 | + | |
17 | +print("cS") | |
18 | + | |
19 | +def cardVoid(cardHost,webHeaders,cardNo): | |
20 | + url = cardHost+"/cardStorage/cardVoid.action" | |
21 | + webHeaders["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8" | |
22 | + data = {"cardNo":cardNo} | |
23 | + res = requests.post(url=url,headers=webHeaders,data=data) | |
24 | + return res | |
25 | + | |
26 | +def queryCardStorageList(cardHost,webHeaders,**kwargs): | |
27 | + """ | |
28 | + 卡片库存查询 | |
29 | + :param cardHost: | |
30 | + :param webHeaders: | |
31 | + :param kwargs: {"rows":"10","page":"1","sort":"create_time","order":"desc","type":"10","cardFace":"buyer","state":"1","cardNo":"210524153943","startDate":"2021-05-24","endDate":"2021-05-24"} | |
32 | + :return: | |
33 | + """ | |
34 | + url = cardHost+"/cardStorage/queryCardStorageList.action" | |
35 | + webHeaders["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8" | |
36 | + data = {"rows":"10","page":"1","sort":"create_time","order":"desc"} | |
37 | + data = dict(data,**kwargs) | |
38 | + res = requests.post(url=url,headers=webHeaders,data=data) | |
39 | + return res | |
40 | + | ... | ... |
commons/api/cardStorageIn.py
0 → 100644
1 | +#coding=utf-8 | |
2 | + | |
3 | +# @Time : 2021/7/16 14:09 | |
4 | +# @Author : Ljq | |
5 | +# @File : cardStorageIn.py | |
6 | +# @Software: PyCharm | |
7 | + | |
8 | + | |
9 | +""" | |
10 | + 入库列表相关接口 | |
11 | +""" | |
12 | + | |
13 | +import requests | |
14 | +import json | |
15 | +from commons.readConf import readConfig | |
16 | + | |
17 | +print("cSI") | |
18 | + | |
19 | +# rC = readConfig() | |
20 | +# cardHost = rC.returnOptionsItems("host","cardHost") | |
21 | + | |
22 | +def getCardType(cardHost,webHeaders): | |
23 | + """ | |
24 | + 获取卡片类型列表 | |
25 | + :param cardHost: | |
26 | + :param webHeaders: | |
27 | + :return: | |
28 | + """ | |
29 | + url = cardHost+"/provider/getLookupList.action" | |
30 | + webHeaders["Content-Type"] = "application/x-www-form-urlencoded" | |
31 | + data={"provider":"cardTypeProvider","queryParams":'{"emptyText":"-- 全部 --"}'} | |
32 | + res = requests.post(url=url,headers=webHeaders,data=data) | |
33 | + return res | |
34 | + | |
35 | +def getCardFace(cardHost,webHeaders): | |
36 | + """ | |
37 | + 获取卡面信息列表 | |
38 | + :param cardHost: | |
39 | + :param webHeaders: | |
40 | + :return: | |
41 | + """ | |
42 | + url = cardHost+"/provider/getLookupList.action" | |
43 | + webHeaders["Content-Type"] = "application/x-www-form-urlencoded" | |
44 | + data={"provider":"cardFaceProvider","queryParams":'{emptyText:"-- 请选择 --"}'} | |
45 | + res = requests.post(url=url,headers=webHeaders,data=data) | |
46 | + return res | |
47 | + | |
48 | +def returnFaceValue(resCardFace,faceNum): | |
49 | + """ | |
50 | + 根据faceNum获取对应卡面的value,目前卡面faceNum值为1-4 | |
51 | + :param resCardFace: | |
52 | + :param faceNum: | |
53 | + :return: | |
54 | + """ | |
55 | + # print("resCardFace",type(resCardFace)) | |
56 | + if resCardFace.json()[0]["text"] == "-- 无--": | |
57 | + # 业务需求当存在 卡面 “--无--” 时,入库不需要传递cardFace | |
58 | + cardFace = None | |
59 | + else: | |
60 | + cardFace = resCardFace.json()[faceNum]["value"] | |
61 | + return cardFace | |
62 | + | |
63 | + | |
64 | +def savaCard(cardHost,webHeaders,startCardNo,endCardNo,cardType=10,cardFace=None): | |
65 | + """ | |
66 | + 卡片入库接口 | |
67 | + :param cardHost: | |
68 | + :param webHeaders: | |
69 | + :param startCardNo: | |
70 | + :param endCardNo: | |
71 | + :param cardType: | |
72 | + :param cardFace: | |
73 | + :return: | |
74 | + """ | |
75 | + amount = int(endCardNo)-int(startCardNo)+1 | |
76 | + url = cardHost + "/cardStorageIn/save.action" | |
77 | + if cardFace == None: | |
78 | + # 当卡面类型为无时,创建入库时,不能传faceNum | |
79 | + data = {"cardType": str(cardType), "startCardNo": str(startCardNo), "endCardNo": str(endCardNo), "amount": amount} | |
80 | + else: | |
81 | + data = {"cardType": str(cardType), "cardFace": cardFace, "startCardNo": str(startCardNo), "endCardNo": str(endCardNo), "amount": amount} | |
82 | + webHeaders["Content-Type"] = "application/json; charset=UTF-8" | |
83 | + print("savaCard data ----> ",data) | |
84 | + res = requests.post(url=url, headers=webHeaders, data=json.dumps(data)) | |
85 | + return res | |
86 | + | |
87 | +def queryList(cardHost=None,webHeaders=None,**searshData): | |
88 | + """ | |
89 | + 入库列表查询 | |
90 | + :param cardHost: | |
91 | + :param webHeaders: | |
92 | + :param searshData: | |
93 | + :return: | |
94 | + """ | |
95 | + storageInListUrl = cardHost + "/cardStorageIn/queryList.action" | |
96 | + webHeaders["Content-Type"] = "application/x-www-form-urlencoded" | |
97 | + storageInSearshData = {"rows": "10", "page": "1", "sort": "create_time", "order": "desc", "startDate": None, | |
98 | + "endDate": None} | |
99 | + storageInSearshData = dict(storageInSearshData,**searshData) | |
100 | + # print("storageInSearshData[i]---->",storageInSearshData) | |
101 | + res = requests.post(url=storageInListUrl, headers=webHeaders, data=storageInSearshData) | |
102 | + return res | |
103 | + | |
104 | +def delCard(cardHost=None,webHeaders=None,ids=None): | |
105 | + """ | |
106 | + 删除入库记录 | |
107 | + :param cardHost: | |
108 | + :param webHeaders: | |
109 | + :param ids: | |
110 | + :return: | |
111 | + """ | |
112 | + storageInListUrl = cardHost + "/cardStorageIn/del.action" | |
113 | + webHeaders["Content-Type"] = "application/x-www-form-urlencoded" | |
114 | + delCardData = {"ids":ids} | |
115 | + res = requests.post(url=storageInListUrl, headers=webHeaders, data=delCardData) | |
116 | + return res | |
0 | 117 | \ No newline at end of file | ... | ... |
commons/api/cardStorageOut.py
0 → 100644
1 | +#coding=utf-8 | |
2 | + | |
3 | +# @Time : 2021/5/20 17:41 | |
4 | +# @Author : Ljq | |
5 | +# @File : cardStorageOut.py | |
6 | +# @Software: PyCharm | |
7 | + | |
8 | + | |
9 | +""" | |
10 | + 卡片出库接口 | |
11 | +""" | |
12 | + | |
13 | +import requests | |
14 | +import json | |
15 | +import re | |
16 | +import time | |
17 | +from commons.scripts import dealContentType as dCT | |
18 | + | |
19 | +def cardAddOut(cardHost=None,webHeaders=None,**kwargs): | |
20 | + """ | |
21 | + 卡片出库接口 | |
22 | + :param cardHost: | |
23 | + :param webHeaders: | |
24 | + :param kwargs: | |
25 | + :return: | |
26 | + """ | |
27 | + url = cardHost+"/cardStorage/addOut.action" | |
28 | + webHeaders["Content-Type"] = "application/json; charset=UTF-8" | |
29 | + data={"applyUserName":"沈阳长歌","applyUserId":"230","applyUserCode":"scgy","amount":"1","cardNos":"210520174412"} | |
30 | + data = dict(data,**kwargs) | |
31 | + # print("data---->",data) | |
32 | + res = requests.post(url=url,headers=webHeaders,data=json.dumps(data)) | |
33 | + return res | |
34 | + | |
35 | +def getOutPage(cardHost=None,webHeaders=None,**kwargs): | |
36 | + """ | |
37 | + 出库列表查询 | |
38 | + :param cardHost: | |
39 | + :param webHeaders: | |
40 | + :param kwargs:{"rows":"10","page":"1","sort":"apply_time","order":"desc","cardNo":"210524144001","applyUserName":"长歌","applyUserId":"93","startDate":"2021-05-24 00:00:00","endDate":"2021-05-24 23:59:59"} | |
41 | + :return: | |
42 | + """ | |
43 | + url = cardHost+"/cardStorage/outPage.action" | |
44 | + webHeaders["Content-Type"] = "application/x-www-form-urlencoded" | |
45 | + data = {"rows": "10", "page": "1", "sort": "apply_time", "order": "desc"} | |
46 | + data = dict(data,**kwargs) | |
47 | + # print("data---->",data) | |
48 | + res = requests.post(url=url, headers=webHeaders, data=data) | |
49 | + return res | |
50 | + | |
51 | +def getCardType(cardHost=None,webHeaders=None,**kwargs): | |
52 | + """ | |
53 | + 获取卡片类别 | |
54 | + :param cardHost: | |
55 | + :param webHeaders: | |
56 | + :param kwargs: | |
57 | + :return: | |
58 | + """ | |
59 | + url = cardHost+"/provider/getLookupList.action" | |
60 | + webHeaders = dCT.urlCode(webHeaders) | |
61 | + data = {'provider':'cardTypeProvider','queryParams':'{"emptyText":"-- 请选择 --"}'} | |
62 | + res = requests.post(url=url,headers=webHeaders,data=data) | |
63 | + return res | |
64 | + | |
65 | +def getCardFace(cardHost=None,webHeaders=None,**kwargs): | |
66 | + """ | |
67 | + 获取卡面信息 | |
68 | + :param cardHost: | |
69 | + :param webHeaders: | |
70 | + :param kwargs: | |
71 | + :return: | |
72 | + """ | |
73 | + url = cardHost + "/provider/getLookupList.action" | |
74 | + webHeaders = dCT.urlCode(webHeaders) | |
75 | + data = {'provider':'cardFaceProvider','queryParams':'{emptyText:"-- 请选择 --"}'} | |
76 | + res = requests.post(url=url, headers=webHeaders, data=data) | |
77 | + return res | |
78 | + | |
79 | +def checkCardForOut(cardHost=None,webHeaders=None,**kwargs): | |
80 | + """ | |
81 | + 检验当前卡片选择的卡面是否正确 | |
82 | + :param cardHost: | |
83 | + :param webHeaders: | |
84 | + :param kwargs: | |
85 | + :return: | |
86 | + """ | |
87 | + url = cardHost+"/cardStorage/checkCardForOut.action" | |
88 | + webHeaders= dCT.urlCode(webHeaders) | |
89 | + data = {"cardNo":"","cardType":"10","cardFace":""} | |
90 | + data=dict(data,**kwargs) | |
91 | + res = requests.get(url=url,headers=webHeaders,params=data) | |
92 | + return res | |
93 | + | |
94 | +def getUserInfo(cardHost=None,webHeaders=None,**kwargs): | |
95 | + url = cardHost+"/user/listByKeyword.action" | |
96 | + webHeaders=dCT.urlCode(webHeaders) | |
97 | + data={"name":"scgy","keyword":"scgy"} | |
98 | + data=dict(data,**kwargs) | |
99 | + res = requests.post(url=url,headers=webHeaders,data=data) | |
100 | + return res | |
101 | + | |
102 | +def getOutListDetail(cardHost=None,webHeaders=None,id=None): | |
103 | + url = cardHost+"/cardStorage/outDetail.html" | |
104 | + webHeaders = dCT.urlCode(webHeaders) | |
105 | + data = {"id":str(id)} | |
106 | + res = requests.get(url=url,headers=webHeaders,params=data) | |
107 | + return res | |
108 | + | |
109 | +def getOutCardDetail(cardHost=None,webHeaders=None,**kwargs): | |
110 | + listRes = getOutPage(cardHost=cardHost, webHeaders=webHeaders,**kwargs) | |
111 | + firstId = listRes.json()["rows"][0]["id"] | |
112 | + # 查询出库详情 | |
113 | + resDetail = getOutListDetail(cardHost=cardHost, webHeaders=webHeaders, id=firstId) | |
114 | + outCardDetail = re.findall("<ul><li>(.*?)</li></ul>", resDetail.text) | |
115 | + return sorted(outCardDetail) | |
0 | 116 | \ No newline at end of file | ... | ... |
commons/api/doLogin.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | |
2 | + | |
3 | +# @Time : 2021/7/16 14:45 | |
4 | +# @Author : Ljq | |
5 | +# @File : doLogin.py | |
6 | +# @Software: PyCharm | |
7 | + | |
8 | +""" | |
9 | + | |
10 | +""" | |
11 | + | |
12 | +import requests | |
13 | +import json | |
14 | +from commons.readConf import readConfig | |
15 | + | |
16 | +class doLogin(): | |
17 | + def __init__(self): | |
18 | + rC = readConfig() | |
19 | + self.userName = rC.returnOptionsItems("loginInfo","userName") | |
20 | + self.password = rC.returnOptionsItems("loginInfo","password") | |
21 | + self.loginUrl = rC.returnOptionsItems("host","uapHost")+"/api/authenticationApi/loginWeb" | |
22 | + self.loginData = {"userName":self.userName,"password":self.password} | |
23 | + self.webHeaders = {"X-Requested-With":"XMLHttpRequest", | |
24 | + "Content-Type":"application/x-www-form-urlencoded", | |
25 | + "Cookie":"UAP_accessToken=${UAP_accessToken}; UAP_refreshToken=${UAP_refreshToken};UAP_firmId=${UAP_firmId}"} | |
26 | + | |
27 | + self.clientHeaders={"UAP_accessToken":"${UAP_accessToken}", | |
28 | + "UAP_refreshToken":"${UAP_refreshToken}", | |
29 | + "UAP_firmId":"${UAP_firmId}", | |
30 | + "Cookie":"UAP_accessToken=${UAP_accessToken}; UAP_refreshToken=${UAP_refreshToken}", | |
31 | + "Content-Type":"application/json"} | |
32 | + | |
33 | + def loginUser(self): | |
34 | + """ | |
35 | + | |
36 | + :return: | |
37 | + """ | |
38 | + # 返回登录信息,以及可用headers,clientHeaders用户客户端操作header,webHeaders用于web页面使用headers | |
39 | + res = requests.post(url=self.loginUrl,data=json.dumps(self.loginData)) | |
40 | + UAP_accessToken,UAP_refreshToken,UAP_firmId=res.json()["data"]["accessToken"],res.json()["data"]["refreshToken"],res.json()["data"]["user"]["firmId"] | |
41 | + webHeadersCookie = "UAP_accessToken="+UAP_accessToken+"; UAP_refreshToken="+UAP_refreshToken+";UAP_firmId="+str(UAP_firmId) | |
42 | + clientHeadersCookie = "UAP_accessToken="+UAP_accessToken+"; UAP_refreshToken="+UAP_refreshToken | |
43 | + self.webHeaders["Cookie"] = webHeadersCookie | |
44 | + self.clientHeaders["UAP_accessToken"] = UAP_accessToken | |
45 | + self.clientHeaders["UAP_refreshToken"]= UAP_refreshToken | |
46 | + self.clientHeaders["UAP_firmId"] = str(UAP_firmId) | |
47 | + self.clientHeaders["Cookie"] = clientHeadersCookie | |
48 | + return self.webHeaders,self.clientHeaders,res.json() | |
49 | + | |
50 | +# a = doLogin() | |
51 | +# c,v,b = a.loginUser() | |
52 | +# print(b) | |
0 | 53 | \ No newline at end of file | ... | ... |
commons/api/openCard.py
0 → 100644
1 | +#coding=utf-8 | |
2 | + | |
3 | +# @Time : 2021/7/16 14:09 | |
4 | +# @Author : Ljq | |
5 | +# @File : openMasterCard.py | |
6 | +# @Software: PyCharm | |
7 | + | |
8 | + | |
9 | +""" | |
10 | + 主卡开卡页面接口 | |
11 | +""" | |
12 | + | |
13 | +import requests | |
14 | +import json | |
15 | +import re | |
16 | +import time | |
17 | +from interface.scripts import dealContentType as dCT | |
18 | + | |
19 | +def getCustomerInfo(gatewayHost=None,clientHeaders=None,cCNum=360101199301010275): | |
20 | + """ | |
21 | + 查询输入的证件号是否有匹配客户信息 | |
22 | + :param cardHost: | |
23 | + :param clientHeaders: | |
24 | + :param cCNum: | |
25 | + :return: | |
26 | + """ | |
27 | + url = gatewayHost+"/card-web/card/getCustomerInfo.action" | |
28 | + clientHeaders = dCT.jsonCT(clientHeaders) | |
29 | + data = {"customerCertificateNumber":str(cCNum)} | |
30 | + res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data)) | |
31 | + return res | |
32 | + | |
33 | +def getSubTypeName(gatewayHost=None,clientHeaders=None,customerId=131176): | |
34 | + """ | |
35 | + 查询客户身份类型名称 | |
36 | + :param gatewayHost: | |
37 | + :param clientHeaders: | |
38 | + :param customerId: | |
39 | + :return: | |
40 | + """ | |
41 | + url = gatewayHost+f"/card-web/customer/getSubTypeName.action?customerId={customerId}" | |
42 | + res = requests.post(url=url,headers=clientHeaders) | |
43 | + return res | |
44 | + | |
45 | +def checkNewCardNo(gatewayHost=None,clientHeaders=None,**kwargs): | |
46 | + """ | |
47 | + 校验卡与当前客户类型状态是否匹配 | |
48 | + :param gatewayHost: | |
49 | + :param clientHeaders: | |
50 | + :param kwargs: 主卡:{"cardNo":"888810032426","cardType":10,"customerType":"in_province","customerId":131167} | |
51 | + 副卡:{"cardNo":"888800001130","cardType":20} | |
52 | + :return: | |
53 | + """ | |
54 | + url = gatewayHost+"/card-web/card/checkNewCardNo.action" | |
55 | + clientHeaders = dCT.jsonCT(clientHeaders) | |
56 | + print("kwargs ------------->",kwargs) | |
57 | + if "cardType" not in kwargs or kwargs["cardType"]==10: | |
58 | + data={"cardNo":"888810032426","cardType":10,"customerType":"in_province","customerId":131167} | |
59 | + # elif kwargs["cardType"]==10: | |
60 | + # data = {"cardNo": "888810032426", "cardType": 10, "customerType": "in_province", "customerId": 131167} | |
61 | + else: | |
62 | + data={} | |
63 | + data = dict(data,**kwargs) | |
64 | + print(data) | |
65 | + res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data)) | |
66 | + return res | |
67 | + | |
68 | +def getOpenCardFee(gatewayHost=None,clientHeaders=None): | |
69 | + url = gatewayHost+"/card-web/card/getOpenCardFee.action" | |
70 | + res = requests.get(url=url,headers=clientHeaders) | |
71 | + return res | |
72 | + | |
73 | +def openMasterCard(gatewayHost=None,clientHeaders=None,**kwargs): | |
74 | + """ | |
75 | + 开卡接口 | |
76 | + :param gatewayHost: | |
77 | + :param clientHeaders: | |
78 | + :param kwargs: {"customerName":"长歌园外买家自动化用户不要动","customerType":"outside_buyer","customerId":131183, | |
79 | + "customerOrganizationType":"individual","customerCredentialType":"ID","customerContactsPhone":"18080001015", | |
80 | + "loginPwd":"111111","cardNo":"888810005703","customerCertificateNumber":"230681202105267887","cardType":10, | |
81 | + "costFee":888,"customerCode":"00130892","name":"长歌", | |
82 | + "createSource":1,"holdName":"长歌园外买家自动化用户不要动","holdContactsPhone":"18080001015","customerSyncModifyHoldinfo":1} | |
83 | + :return: | |
84 | + """ | |
85 | + url = gatewayHost+"/card-web/card/openMasterCard.action" | |
86 | + clientHeaders = dCT.jsonCT(clientHeaders) | |
87 | + data={"customerName":"","customerType":"","customerId":None,"customerOrganizationType":"","customerCredentialType":"","customerContactsPhone":"","loginPwd":"","cardNo":"","customerCertificateNumber":"","cardType":None,"costFee":None,"customerCode":"","name":"","createSource":1,"holdName":"","holdContactsPhone":"","customerSyncModifyHoldinfo":1} | |
88 | + data=dict(data,**kwargs) | |
89 | + print("openMasterCard data ----> ",data) | |
90 | + res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data)) | |
91 | + return res | |
92 | + | |
93 | +def openMasterCardDef(gatewayHost=None,clientHeaders=None,cCNum=None,cardNo=None,loginPwd=111111,applyUserName=None): | |
94 | + | |
95 | + # 获取手续费 | |
96 | + costFee = getOpenCardFee(gatewayHost=gatewayHost, clientHeaders=clientHeaders).json()["data"] | |
97 | + print(costFee) | |
98 | + # 获取客户信息 | |
99 | + resCusInfo = getCustomerInfo(gatewayHost=gatewayHost, clientHeaders=clientHeaders, | |
100 | + cCNum=cCNum).json()["data"] | |
101 | + print(resCusInfo) | |
102 | + # 客户信息准备 | |
103 | + customerName = resCusInfo["name"] | |
104 | + customerType = resCusInfo["customerType"] | |
105 | + customerId = resCusInfo["id"] | |
106 | + customerOrganizationType = resCusInfo["organizationType"] | |
107 | + customerCredentialType = resCusInfo["certificateType"] | |
108 | + customerContactsPhone = resCusInfo["customerContactsPhone"] | |
109 | + customerCertificateNumber = resCusInfo["certificateNumber"] | |
110 | + customerCode = resCusInfo["code"] | |
111 | + name = applyUserName | |
112 | + holdName = resCusInfo["name"] | |
113 | + holdContactsPhone = resCusInfo["customerContactsPhone"] | |
114 | + | |
115 | + # 卡片状态校验 | |
116 | + resCheck = checkNewCardNo(gatewayHost=gatewayHost, clientHeaders=clientHeaders, | |
117 | + cardNo=cardNo, | |
118 | + customerId=customerId, | |
119 | + customerType=customerType) | |
120 | + print(resCheck.json()) | |
121 | + # assert "200" == resCheck.json()["code"], "卡片校验失败" | |
122 | + | |
123 | + # 开卡 | |
124 | + print("开始开卡") | |
125 | + resOpenCard = openMasterCard(gatewayHost=gatewayHost, clientHeaders=clientHeaders, | |
126 | + cardNo=cardNo, | |
127 | + costFee=costFee, customerName=customerName, customerType=customerType, | |
128 | + customerId=customerId, loginPwd=loginPwd, | |
129 | + customerOrganizationType=customerOrganizationType, | |
130 | + customerCredentialType=customerCredentialType, | |
131 | + customerContactsPhone=customerContactsPhone, | |
132 | + customerCertificateNumber=customerCertificateNumber, customerCode=customerCode, | |
133 | + name=name, holdName=holdName, holdContactsPhone=holdContactsPhone, cardType=10) | |
134 | + print("resOpenCard.json()", resOpenCard.json()) | |
135 | + return resOpenCard | |
136 | + | |
137 | +def getAccountInfo(gatewayHost=None,clientHeaders=None,cardNo=None): | |
138 | + url = gatewayHost+"/card-web/card/getAccountInfo.action" | |
139 | + clientHeaders=dCT.jsonCT(clientHeaders) | |
140 | + data = {"cardNo":str(cardNo)} | |
141 | + res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data)) | |
142 | + return res | |
143 | + | |
144 | +def openSlaveCard(gatewayHost=None,clientHeaders=None,**kwargs): | |
145 | + """ | |
146 | + | |
147 | + :param gatewayHost: | |
148 | + :param clientHeaders: | |
149 | + :param kwargs:{"customerName":"长歌一","customerType":null,"customerId":131136,"customerOrganizationType":"individual", | |
150 | + "customerCredentialType":"ID","customerContactsPhone":"18050005001","loginPwd":"111111","cardNo":"800000020435", | |
151 | + "customerCertificateNumber":"110101200803075932","cardType":20,"costFee":999,"customerCode":"00130845", | |
152 | + "name":"沈阳长歌","parentAccountId":104547,"createSource":1,"parentLoginPwd":"111111","holdName":"长歌一", | |
153 | + "holdContactsPhone":"18050005001","customerSyncModifyHoldinfo":1} | |
154 | + :return: | |
155 | + """ | |
156 | + url = gatewayHost+"/card-web/card/openSlaveCard.action" | |
157 | + clientHeaders = dCT.jsonCT(clientHeaders) | |
158 | + data={"customerName":"长歌一","customerType":None,"customerId":131136,"customerOrganizationType":"individual","customerCredentialType":"ID","customerContactsPhone":"18050005001","loginPwd":"111111","cardNo":"800000020435","customerCertificateNumber":"110101200803075932","cardType":20,"costFee":999,"customerCode":"00130845","name":"沈阳长歌","parentAccountId":104547,"createSource":1,"parentLoginPwd":"111111","holdName":"长歌一","holdContactsPhone":"18050005001","customerSyncModifyHoldinfo":1} | |
159 | + data = dict(data,**kwargs) | |
160 | + res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data)) | |
161 | + return res | |
162 | + | |
163 | +def openSlaveCardDef(gatewayHost=None,clientHeaders=None,cardNo=None,slaveCardNo=None,loginPwd=None,applyUserName=None,parentLoginPwd=None): | |
164 | + costFee = getOpenCardFee(gatewayHost=gatewayHost, clientHeaders=clientHeaders).json()["data"] | |
165 | + print(costFee) | |
166 | + resGet = getAccountInfo(gatewayHost=gatewayHost, clientHeaders=clientHeaders, cardNo=cardNo).json()["data"] | |
167 | + print("resGet ---> ", resGet) | |
168 | + customerName = resGet["customerName"] | |
169 | + customerId = resGet["customerId"] | |
170 | + customerCredentialType = resGet["customerCertificateType"] | |
171 | + customerContactsPhone = resGet["customerContactsPhone"] | |
172 | + customerCertificateNumber = resGet["customerCertificateNumber"] | |
173 | + cardType = 20 | |
174 | + customerCode = resGet["customerCode"] | |
175 | + name = applyUserName | |
176 | + parentAccountId = resGet["accountId"] | |
177 | + holdName = customerName | |
178 | + holdContactsPhone = customerContactsPhone | |
179 | + resOpenSlaveCard = openSlaveCard(gatewayHost=gatewayHost, clientHeaders=clientHeaders, | |
180 | + customerName=customerName, | |
181 | + customerId=customerId, customerContactsPhone=customerContactsPhone, | |
182 | + loginPwd=loginPwd, cardNo=slaveCardNo, | |
183 | + customerCertificateNumber=customerCertificateNumber, cardType=cardType, | |
184 | + costFee=costFee, customerCode=customerCode, | |
185 | + name=name, parentAccountId=parentAccountId, parentLoginPwd=parentLoginPwd, | |
186 | + holdName=holdName, | |
187 | + holdContactsPhone=holdContactsPhone, | |
188 | + customerCredentialType=customerCredentialType | |
189 | + ) | |
190 | + return resOpenSlaveCard | |
0 | 191 | \ No newline at end of file | ... | ... |
commons/clientSession.py
commons/readConf.py
... | ... | @@ -22,9 +22,10 @@ class readConfig(object): |
22 | 22 | self.file_name = r'test_config_hg' |
23 | 23 | if self.evn_name == 'nt': |
24 | 24 | self.relative_path = r'/config/marketConfig/' |
25 | - self.file_path = os.path.abspath(os.path.join(os.getcwd(), "../..")) + self.relative_path+self.file_name | |
25 | + self.file_path = os.path.abspath(os.path.join(os.getcwd())) + self.relative_path+self.file_name | |
26 | + # self.file_path = os.path.abspath(os.path.join(os.getcwd(), "../")) + self.relative_path+self.file_name | |
26 | 27 | elif self.evn_name == 'posix': |
27 | - self.relative_path = r'/src/config/marketConfig/' | |
28 | + self.relative_path = r'/config/marketConfig/' | |
28 | 29 | self.file_path = os.path.abspath(os.path.join(os.getcwd())) + self.relative_path + self.file_name |
29 | 30 | # self.file_path = os.getcwd() |
30 | 31 | print(self.file_path) | ... | ... |
commons/scripts/__init__.py
0 → 100644
commons/scripts/dealContentType.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | |
2 | + | |
3 | +# @Time : 2021/7/16 14:51 | |
4 | +# @Author : Ljq | |
5 | +# @File : dealContentType.py | |
6 | +# @Software: PyCharm | |
7 | + | |
8 | +""" | |
9 | + 用于hearders中Content-Type格式处理 | |
10 | +""" | |
11 | + | |
12 | +def jsonCT(headers=None): | |
13 | + headers["Content-Type"] = "application/json; charset=UTF-8" | |
14 | + return headers | |
15 | + | |
16 | +def urlCode(headers=None): | |
17 | + headers["Content-Type"] = "application/x-www-form-urlencoded" | |
18 | + return headers | |
0 | 19 | \ No newline at end of file | ... | ... |
config/global_data.conf
main.py
1 | -# This is a sample Python script. | |
1 | +# -*- coding: utf-8 -*- | |
2 | 2 | |
3 | -# Press Shift+F10 to execute it or replace it with your code. | |
4 | -# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. | |
3 | +# @Time : 2021/7/16 15:11 | |
4 | +# @Author : Ljq | |
5 | +# @File : main.py | |
6 | +# @Software: PyCharm | |
5 | 7 | |
8 | +""" | |
6 | 9 | |
7 | -def print_hi(name): | |
8 | - # Use a breakpoint in the code line below to debug your script. | |
9 | - print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. | |
10 | +""" | |
10 | 11 | |
12 | +import os, time | |
13 | +import sys | |
14 | +import unittest | |
15 | +import re | |
16 | +import HTMLTestRunner_cn | |
17 | +import commons.ConfigDB as db | |
18 | +from discover import DiscoveringTestLoader | |
19 | +from commons import SendEmail as em | |
20 | +from commons import common as com | |
21 | +from commons.MySession import my | |
11 | 22 | |
12 | -# Press the green button in the gutter to run the script. | |
13 | -if __name__ == '__main__': | |
14 | - print_hi('PyCharm') | |
15 | 23 | |
16 | -# See PyCharm help at https://www.jetbrains.com/help/pycharm/ | |
24 | +def Create_Testcase_suite(): | |
25 | + '''创建测试套件''' | |
26 | + testunit = unittest.TestSuite() | |
27 | + test_Loader = DiscoveringTestLoader() | |
28 | + discover = test_Loader.discover("./testcase/", pattern='test_*.py', top_level_dir=None) | |
29 | + print(discover) | |
30 | + for test_suite in discover: | |
31 | + testunit.addTests(test_suite) | |
32 | + # print(testunit) | |
33 | + return testunit | |
34 | + | |
35 | + | |
36 | +def Run_Testcase(testsuit): | |
37 | + '''运行测试用例并生成报告''' | |
38 | + now = time.strftime("%Y-%m-%d %H_%M_%S", time.localtime()) | |
39 | + path = os.path.dirname(os.path.abspath(sys.argv[0])) | |
40 | + report_file = path + "/report/" + now + "_result.html" | |
41 | + # 创建报告文件 | |
42 | + fp = open(report_file, 'wb') | |
43 | + | |
44 | + runner = HTMLTestRunner_cn.HTMLTestRunner( | |
45 | + stream=fp, | |
46 | + title=u'重构项目接口测试报告', | |
47 | + description=u'用例简要执行情况如下:(注:报告详细信息需要下载report.html并用浏览器打开)', | |
48 | + verbosity=2) | |
49 | + # 执行用例 | |
50 | + runner.run(testsuit) | |
51 | + # 关闭文件 | |
52 | + fp.close() | |
53 | + return report_file | |
54 | + | |
55 | + | |
56 | +def Send_email(filename): | |
57 | + '''判断邮件发送逻辑''' | |
58 | + l = eval(com.get_global_config("global_data", "email", "list").lower()) | |
59 | + if type(l) != type([]): | |
60 | + raise Exception("error,pls input list type send-email address") | |
61 | + elif len(l) == 0: | |
62 | + print("\n list of send-email is null,won't send email!") | |
63 | + elif len(l) != 0: | |
64 | + for i in l: | |
65 | + print("\n check send-email format : {}".format(i)) | |
66 | + if re.match(r'^[0-9a-zA-Z_]{1,19}@[0-9a-zA-Z]{1,13}\.[com,cn,net]{1,3}$', i): | |
67 | + pass | |
68 | + else: | |
69 | + raise Exception("error,pls check your send-email format") | |
70 | + # 发送邮件 | |
71 | + em.send_email(filename, l) | |
72 | + else: | |
73 | + print("\n Haven't sent the email,pls check send-email address!") | |
74 | + | |
75 | + | |
76 | +if __name__ == "__main__": | |
77 | + # 检测数据库 | |
78 | + db.mysql_conn_test() | |
79 | + # 检测登录接口 | |
80 | + my.check_login("user01") | |
81 | + # 创建测试套,运行测试用例,生成报告 | |
82 | + report = Run_Testcase(Create_Testcase_suite()) | |
83 | + # 发送邮件 | |
84 | + Send_email(report) | |
17 | 85 | \ No newline at end of file | ... | ... |
practice/__init__.py
0 → 100644
practice/classA.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | |
2 | + | |
3 | +# @Time : 2021/7/16 15:31 | |
4 | +# @Author : Ljq | |
5 | +# @File : classA.py | |
6 | +# @Software: PyCharm | |
7 | + | |
8 | +""" | |
9 | + | |
10 | +""" | |
11 | + | |
12 | +import sys | |
13 | +import traceback | |
14 | + | |
15 | +class classA(object): | |
16 | + def __init__(self): | |
17 | + pass | |
18 | + | |
19 | + def doSomeThing(self): | |
20 | + print("classA.doSomeThing") | |
21 | + print(traceback.extract_stack()) | |
22 | + print(traceback.extract_stack()[-2]) | |
23 | + print(traceback.extract_stack()[-2][2]) | |
0 | 24 | \ No newline at end of file | ... | ... |
practice/classB.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | |
2 | + | |
3 | +# @Time : 2021/7/16 15:31 | |
4 | +# @Author : Ljq | |
5 | +# @File : classB.py | |
6 | +# @Software: PyCharm | |
7 | + | |
8 | +""" | |
9 | + | |
10 | +""" | |
11 | + | |
12 | +from practice.classA import classA | |
13 | + | |
14 | +class classB(object): | |
15 | + def __init__(self): | |
16 | + pass | |
17 | + | |
18 | + def cbDoThing(self): | |
19 | + classA().doSomeThing() | |
20 | + | |
21 | +if __name__=="__main__": | |
22 | + classB().cbDoThing() | |
0 | 23 | \ No newline at end of file | ... | ... |
report/test.log
1 | -[2021-07-16 13:26:19] [INFO] : ====================================================================================== | |
2 | -[2021-07-16 13:26:19] [INFO] : http://test.trace.diligrp.com:8393/fieldConfig/doUpdate.action | |
3 | -None | |
4 | -{'moduleType': '1', 'marketId': '8', 'fieldConfigDetailList': [{'fieldName': 'unitPrice', 'jsonPath': '$.unitPrice', 'defaultId': '3', 'displayed': '1', 'required': '0'}, {'fieldName': 'arrivalTallynos', 'jsonPath': '$.arrivalTallynos', 'defaultId': '10', 'displayed': '1', 'required': '0'}, {'fieldName': 'brandName', 'jsonPath': '$.brandName', 'defaultId': '5', 'displayed': '1', 'required': '0'}, {'fieldName': 'truckTareWeight', 'jsonPath': '$.truckTareWeight', 'defaultId': '1', 'displayed': '1', 'required': '0'}, {'fieldName': 'originId', 'jsonPath': '$.originId', 'defaultId': '7', 'displayed': '1', 'required': '0'}, {'fieldName': 'specName', 'jsonPath': '$.specName', 'defaultId': '4', 'displayed': '1', 'required': '0'}, {'fieldName': 'truckType', 'jsonPath': '$.truckType', 'defaultId': '2', 'displayed': '1', 'required': '1', 'availableValueList': ['10', '20']}, {'fieldName': 'imageCertList', 'jsonPath': '$.imageCertList[*]certType', 'defaultId': '11', 'displayed': '1', 'required': '0', 'availableValueList': ['2', '3']}, {'fieldName': 'arrivalDatetime', 'jsonPath': '$.arrivalDatetime', 'defaultId': '9', 'displayed': '1', 'required': '0'}, {'fieldName': 'remark', 'jsonPath': '$.remark', 'defaultId': '8', 'displayed': '1', 'required': '0'}, {'fieldName': 'remark', 'jsonPath': '$.remark', 'defaultId': '6', 'displayed': '1', 'required': '0'}, {'fieldName': 'measureType', 'jsonPath': '$.measureType', 'defaultId': '12', 'displayed': '1', 'required': '1', 'availableValueList': ['10', '20']}]} | |
5 | -{'headers': {'Host': 'test.trace.diligrp.com:8393', 'Connection': 'keep-alive', 'Content-Length': '1378', 'Accept': 'application/json,text/javascript,*/*;q=0.01', 'X-Requested-With': 'XMLHttpRequest', 'User-Agent': 'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/91.0.4472.77Safari/537.36', 'Content-Type': 'application/json', 'Origin': 'http://test.trace.diligrp.com:8393', 'Referer': 'http://test.trace.diligrp.com:8393/fieldConfig/bill.html', 'Accept-Encoding': 'gzip,deflate', 'Accept-Language': 'zh-CN,zh-TW;q=0.9,zh;q=0.8,en;q=0.7'}} | |
6 | -[2021-07-16 13:26:19] [INFO] : ====================================================================================== | |
7 | -[2021-07-16 13:26:19] [INFO] : http://test.trace.diligrp.com:8393/newRegisterBill/doAdd.action | |
8 | -{"registerHeadWeight": "0", "registerHeadRemainWeight": "0", "imageCertList": [], "measureType": 20, "registType": 10, "userId": 516, "arrivalTallynos": [], "arrivalDatetime": "", "truckType": 10, "weight": "111", "weightUnit": 1, "productName": "\u5927\u767d\u83dc", "productId": 2190, "originName": "", "originId": "", "unitPrice": "", "truckTareWeight": "", "remark": "", "specName": "", "brandName": "", "plate": "\u5dddA123456"} | |
9 | -{} | |
10 | - | |
11 | -[2021-07-16 13:26:20] [INFO] : ====================================================================================== | |
12 | -[2021-07-16 13:26:20] [INFO] : http://test.trace.diligrp.com:8393/newRegisterBill/doAdd.action | |
13 | -{"registerHeadWeight": "0", "registerHeadRemainWeight": "0", "imageCertList": [], "measureType": 20, "registType": 10, "userId": 516, "arrivalTallynos": [], "arrivalDatetime": "", "truckType": 10, "weight": "111", "weightUnit": 1, "productName": "\u5927\u767d\u83dc", "productId": 2190, "originName": "", "originId": "", "unitPrice": "", "truckTareWeight": "", "remark": "", "specName": "", "brandName": "", "plate": "\u5dddA123456"} | |
14 | -{} | |
15 | - | |
1 | +[2021-07-16 15:59:34] [INFO] : 发送邮件 | |
2 | +[2021-07-16 15:59:36] [INFO] : 邮件发送完毕 | ... | ... |
testCase/test_addCard.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | |
2 | + | |
3 | +# @Time : 2021/7/16 14:44 | |
4 | +# @Author : Ljq | |
5 | +# @File : test_addCard.py | |
6 | +# @Software: PyCharm | |
7 | + | |
8 | +""" | |
9 | +卡片入库测试 | |
10 | +""" | |
11 | + | |
12 | +import unittest | |
13 | +import requests | |
14 | +import time | |
15 | +import json | |
16 | +import math | |
17 | +import commons.api.cardStorageIn as cSI | |
18 | +import commons.api.cardStock as cS | |
19 | +import commons.api.cardStorageOut as cSO | |
20 | +from commons.readConf import readConfig | |
21 | +from commons.api.doLogin import doLogin | |
22 | +from commons.MySession import mysession | |
23 | + | |
24 | +class test_addCard(unittest.TestCase): | |
25 | + @classmethod | |
26 | + def setUpClass(cls): | |
27 | + # 获取登录信息和可用headers | |
28 | + rC = readConfig() | |
29 | + cls.cardHost = rC.returnOptionsItems("host", "cardHost") | |
30 | + cls.webHeaders,cls.clientHeaders,cls.userInfo = doLogin().loginUser() | |
31 | + cls.applyUserName = cls.userInfo["data"]["user"]["realName"] | |
32 | + cls.applyUserId = cls.userInfo["data"]["user"]["id"] | |
33 | + cls.applyUserCode = cls.userInfo["data"]["user"]["userName"] | |
34 | + # print("self.webHeaders", cls.webHeaders) | |
35 | + # print("self.clientHeaders", cls.clientHeaders) | |
36 | + # print("self.userInfo", cls.userInfo) | |
37 | + | |
38 | + def setUp(self) -> None: | |
39 | + time.sleep(2) | |
40 | + | |
41 | + def test_cardType(self): | |
42 | + """ | |
43 | + 卡类型校验 | |
44 | + :return: | |
45 | + """ | |
46 | + resCardType = cSI.getCardType(cardHost=self.cardHost, webHeaders=self.webHeaders) | |
47 | + preRes = [{"text":"-- 全部 --","value":""},{"text":"主卡","value":10},{"text":"副卡","value":20}] | |
48 | + assert resCardType.json()==preRes,"卡类型信息错误" | |
49 | + | |
50 | + def test_cardFaceCheck(self): | |
51 | + """ | |
52 | + 市场卡面信息校验 | |
53 | + :return: | |
54 | + """ | |
55 | + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders) | |
56 | + print(resCardFace.json()) | |
57 | + if self.userInfo["data"]["user"]["firmId"] == 8: | |
58 | + # 预期结果定义 | |
59 | + preRes = [{'text': '-- 请选择 --', 'value': ''}, {'text': '买方卡', 'value': 'buyer'}, {'text': 'VIP买方卡', 'value': 'buyer_vip'}, {'text': '卖方卡', 'value': 'seller'}, {'text': '司机卡', 'value': 'driver'}] | |
60 | + assert resCardFace.json()==preRes,"当 firmId = 8 时卡面信息错误" | |
61 | + else: | |
62 | + preRes = [{"text":"-- 无--","value":""}] | |
63 | + assert resCardFace.json() == preRes, "当 firmId != 8 时卡面信息错误" | |
64 | + | |
65 | + def test_doCardStorageIn(self): | |
66 | + """ | |
67 | + 卡片入库测试,新添加的卡片能正常的入库 | |
68 | + :return: | |
69 | + """ | |
70 | + # 获取卡面信息 | |
71 | + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders) | |
72 | + cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3) | |
73 | + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime())) | |
74 | + endCardNo = startCardNo + 1 | |
75 | + # 执行入库 | |
76 | + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace) | |
77 | + # print(resSavaCard.json()) | |
78 | + assert resSavaCard.json()["message"]=="OK","入库失败" | |
79 | + resQueryList = cSI.queryList(cardHost=self.cardHost,webHeaders=self.webHeaders) | |
80 | + # 入库卡片号段校验 | |
81 | + assert resQueryList.json()["rows"][0]["cardNoRange"]==str(startCardNo)+"-"+str(endCardNo),"入库的卡片在入库列表不能被查询到" | |
82 | + # 入库数量校验 | |
83 | + assert resQueryList.json()["rows"][0]["amount"]==2,"入库数量错误" | |
84 | + # 入库角色校验 | |
85 | + assert resQueryList.json()["rows"][0]["creator"]==self.userInfo["data"]["user"]["realName"],"入库角色记录正确" | |
86 | + assert resQueryList.json()["rows"][0]["creatorId"] == self.userInfo["data"]["user"]["id"], "入库角色记录正确" | |
87 | + # resQueryList.json()["rows"][0]["cardFaceText"] | |
88 | + if self.userInfo["data"]["user"]["firmId"] == 8: | |
89 | + assert cardFace==resQueryList.json()["rows"][0]["cardFace"],"记录的卡面信息与实际卡面不一致" | |
90 | + else: | |
91 | + assert "cardFaceText" not in resQueryList.text,"记录的卡面信息与实际卡面不一致" | |
92 | + | |
93 | + def test_duplicateStorageIn(self): | |
94 | + """ | |
95 | + 测试卡片不能被重复入库 | |
96 | + :return: | |
97 | + """ | |
98 | + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders) | |
99 | + cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3) | |
100 | + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime())) | |
101 | + endCardNo = startCardNo+1 | |
102 | + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace) | |
103 | + assert resSavaCard.json()["message"]=="OK","入库失败" | |
104 | + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace) | |
105 | + assert resSavaCard.json()["message"]=="入库失败,包含重复卡号%s~%s"%(startCardNo,endCardNo),"卡片不能重复入库验证失败" | |
106 | + | |
107 | + def test_openCardStorageIn(self): | |
108 | + """ | |
109 | + 入库列表查询测试 | |
110 | + :return: | |
111 | + """ | |
112 | + # 全列表查询 | |
113 | + resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders) | |
114 | + # print(resQueryList.json()["total"]) | |
115 | + assert resQueryList.json()["total"]>200,"页数小于10,查询结果可能存在错误" | |
116 | + | |
117 | + # 查询当天入库的入库记录,判断所得的查询记录的日期都是当天的为测试通过 | |
118 | + startDate = str(time.strftime("%Y-%m-%d 00:00:00", time.localtime())) | |
119 | + endDate = str(time.strftime("%Y-%m-%d 23:59:59", time.localtime())) | |
120 | + resQueryLista = cSI.queryList(cardHost=self.cardHost,webHeaders=self.webHeaders,startDate=startDate,endDate=endDate) | |
121 | + dateList=[] | |
122 | + pageNums = math.ceil(resQueryLista.json()["total"]/10) | |
123 | + for pageNum in range(pageNums): | |
124 | + resQueryLista = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders, startDate=startDate, | |
125 | + endDate=endDate,page=str(pageNum+1)) | |
126 | + dateList = dateList+[i["createTime"] for i in resQueryLista.json()["rows"]] | |
127 | + assert [] == [i for i in dateList if i<startDate or i>endDate],"查询结果错误,查询出非当天的入库信息" | |
128 | + | |
129 | + def test_addMasterCard(self): | |
130 | + """ | |
131 | + 添加主卡 | |
132 | + :return: | |
133 | + """ | |
134 | + resCardType = cSI.getCardType(cardHost=self.cardHost,webHeaders=self.webHeaders) | |
135 | + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders) | |
136 | + cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3) | |
137 | + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime())) | |
138 | + endCardNo = startCardNo+1 | |
139 | + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace) | |
140 | + resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders) | |
141 | + assert resQueryList.json()["rows"][0]["cardType"]==10,"卡片类型错误" | |
142 | + | |
143 | + | |
144 | + def test_addSlaveCard(self): | |
145 | + """ | |
146 | + 添加副卡 | |
147 | + :return: | |
148 | + """ | |
149 | + resCardType = cSI.getCardType(cardHost=self.cardHost,webHeaders=self.webHeaders) | |
150 | + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime())) | |
151 | + endCardNo = startCardNo+1 | |
152 | + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardType=20) | |
153 | + print(resSavaCard.json()) | |
154 | + resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders) | |
155 | + assert resQueryList.json()["rows"][0]["cardType"] == 20, "卡片类型错误" | |
156 | + assert resQueryList.json()["rows"][0]["cardTypeText"] == "副卡", "卡片类型错误" | |
157 | + assert "cardFaceText" not in str(resQueryList.json()["rows"][0]),"副卡不应该存在卡面" | |
158 | + | |
159 | + | |
160 | + def test_delStorageInRecord(self): | |
161 | + """ | |
162 | + 正常删除卡片记录 | |
163 | + :return: | |
164 | + """ | |
165 | + # 新增加一条入库记录用于删除 | |
166 | + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders) | |
167 | + cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3) | |
168 | + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime())) | |
169 | + endCardNo = startCardNo + 1 | |
170 | + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace) | |
171 | + assert resSavaCard.json()["message"]=="OK","入库失败" | |
172 | + resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders) | |
173 | + ida = resQueryList.json()['rows'][0]['id'] | |
174 | + resDel = cSI.delCard(cardHost=self.cardHost,webHeaders=self.webHeaders,ids=ida) | |
175 | + assert resDel.json()["message"]=="OK","删除失败,入库记录未被成功删除" | |
176 | + resQueryListB = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders) | |
177 | + idb = resQueryListB.json()['rows'][0]['id'] | |
178 | + print(ida,"----------------",idb) | |
179 | + assert ida!=idb,"删除功能异常,记录未被删除" | |
180 | + | |
181 | + def test_delStorageInRecordFail_delCard(self): | |
182 | + """ | |
183 | + 已作废的卡片不能被删除 | |
184 | + :return: | |
185 | + """ | |
186 | + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders) | |
187 | + cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3) | |
188 | + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime())) | |
189 | + endCardNo = startCardNo+1 | |
190 | + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace) | |
191 | + # 卡片作废 | |
192 | + cS.cardVoid(cardHost=self.cardHost,webHeaders=self.webHeaders,cardNo=startCardNo) | |
193 | + # 删除入库记录 | |
194 | + resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders) | |
195 | + ida = resQueryList.json()['rows'][0]['id'] | |
196 | + resDel = cSI.delCard(cardHost=self.cardHost, webHeaders=self.webHeaders, ids=ida) | |
197 | + print(resDel.json()) | |
198 | + assert resDel.json()["message"]=="有部分卡片已出库或作废,删除失败","已作废的卡片不能被删除" | |
199 | + | |
200 | + def test_delStorageInRecordFail_cardOut(self): | |
201 | + """ | |
202 | + 存在出库卡片的入库记录,不能进行删除 | |
203 | + :return: | |
204 | + """ | |
205 | + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders) | |
206 | + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=3) | |
207 | + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime())) | |
208 | + endCardNo = startCardNo + 1 | |
209 | + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo, | |
210 | + endCardNo=endCardNo, cardFace=cardFace) | |
211 | + # 卡片出库 | |
212 | + acc = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=str(startCardNo),applyUserName=self.applyUserName,applyUserCode=self.applyUserCode,applyUserId=self.applyUserId) | |
213 | + # print(acc.json()) | |
214 | + # 删除入库记录 | |
215 | + resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders) | |
216 | + ida = resQueryList.json()['rows'][0]['id'] | |
217 | + resDel = cSI.delCard(cardHost=self.cardHost, webHeaders=self.webHeaders, ids=ida) | |
218 | + # print(resDel.json()) | |
219 | + assert resDel.json()["message"] == "有部分卡片已出库或作废,删除失败", "已出库的卡片不能被删除" | |
220 | + | |
221 | + @classmethod | |
222 | + def tearDownClass(cls): | |
223 | + print("tearDown") | |
224 | + | |
225 | + def tearDown(self) -> None: | |
226 | + pass | |
227 | + | |
228 | +if __name__== "__main__": | |
229 | + unittest.main() | |
0 | 230 | \ No newline at end of file | ... | ... |