Commit 93b32fa6545dc54429fe4824dbe426a3e5857b92

Authored by liujiqiang
1 parent 2257f5d6

测试用例添加

.idea/card-app.iml
@@ -4,5 +4,6 @@ @@ -4,5 +4,6 @@
4 <content url="file://$MODULE_DIR$" /> 4 <content url="file://$MODULE_DIR$" />
5 <orderEntry type="inheritedJdk" /> 5 <orderEntry type="inheritedJdk" />
6 <orderEntry type="sourceFolder" forTests="false" /> 6 <orderEntry type="sourceFolder" forTests="false" />
  7 + <orderEntry type="module" module-name="cardApp" />
7 </component> 8 </component>
8 </module> 9 </module>
9 \ No newline at end of file 10 \ No newline at end of file
.idea/modules.xml
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 <component name="ProjectModuleManager"> 3 <component name="ProjectModuleManager">
4 <modules> 4 <modules>
5 <module fileurl="file://$PROJECT_DIR$/.idea/card-app.iml" filepath="$PROJECT_DIR$/.idea/card-app.iml" /> 5 <module fileurl="file://$PROJECT_DIR$/.idea/card-app.iml" filepath="$PROJECT_DIR$/.idea/card-app.iml" />
  6 + <module fileurl="file://$PROJECT_DIR$/../../../../08自动化项目/09AutoTest/cardApp/.idea/cardApp.iml" filepath="$PROJECT_DIR$/../../../../08自动化项目/09AutoTest/cardApp/.idea/cardApp.iml" />
6 </modules> 7 </modules>
7 </component> 8 </component>
8 </project> 9 </project>
9 \ No newline at end of file 10 \ No newline at end of file
.idea/vcs.xml
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project version="4"> 2 <project version="4">
3 <component name="VcsDirectoryMappings"> 3 <component name="VcsDirectoryMappings">
4 - <mapping directory="$PROJECT_DIR$" vcs="Git" /> 4 + <mapping directory="" vcs="Git" />
5 </component> 5 </component>
6 </project> 6 </project>
7 \ No newline at end of file 7 \ No newline at end of file
commons/api/cardLostAndUnLost.py 0 → 100644
  1 +#coding=utf-8
  2 +
  3 +# @Time : 2021/5/27 10:23
  4 +# @Author : Ljq
  5 +# @File : cardLostAndUnLost.py
  6 +# @Software: PyCharm
  7 +
  8 +
  9 +"""
  10 + 卡片挂失解挂
  11 +"""
  12 +
  13 +import requests
  14 +import json
  15 +from commons.readConf import readConfig
  16 +from commons.scripts import dealContentType as dCT
  17 +
  18 +def getAccountInfo(gatewayHost=None,clientHeaders=None,cardNo=None):
  19 + """获取卡片信息"""
  20 + url = gatewayHost+"/card-web/card/getAccountInfo.action"
  21 + clientHeaders=dCT.jsonCT(clientHeaders)
  22 + data = {"cardNo":str(cardNo)}
  23 + res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data))
  24 + return res
  25 +
  26 +def lossCard(gatewayHost=None,clientHeaders=None,**kwargs):
  27 + """
  28 + 卡片挂失
  29 + :param gatewayHost:
  30 + :param clientHeaders:
  31 + :param kwargs:{"cardNo":"888810010670","accountId":104547,"loginPwd":"111111","customerId":131136}
  32 + :return:
  33 + """
  34 + url = gatewayHost+"/card-web/card/reportLossCard.action"
  35 + clientHeaders=dCT.jsonCT(clientHeaders)
  36 + data = {"cardNo":"888810010670","accountId":104547,"loginPwd":"111111","customerId":131136}
  37 + data = dict(data,**kwargs)
  38 + # print(data)
  39 + res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data))
  40 + return res
  41 +
  42 +def getByCardForUnLost(gatewayHost=None,clientHeaders=None,cardNo=None):
  43 + """
  44 + 获取挂失卡信息
  45 + :param gatewayHost:
  46 + :param clientHeaders:
  47 + :param cardNo:
  48 + :return:
  49 + """
  50 + url = gatewayHost+f"/card-web/card/getByCardForUnLost.action?cardNo={cardNo}"
  51 + clientHeaders=dCT.jsonCT(clientHeaders)
  52 + res = requests.get(url=url,headers=clientHeaders)
  53 + return res
  54 +
  55 +def unLostCard(gatewayHost=None,clientHeaders=None,**kwargs):
  56 + """获取卡片信息"""
  57 + url = gatewayHost+"/card-web/card/unLostCard.action"
  58 + clientHeaders=dCT.jsonCT(clientHeaders)
  59 + data = {"cardNo":"888810010670","accountId":104547,"loginPwd":"111111","customerId":131136}
  60 + data = dict(data,**kwargs)
  61 + # print(data)
  62 + res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data))
  63 + return res
0 \ No newline at end of file 64 \ No newline at end of file
commons/api/changeCard.py 0 → 100644
  1 +#coding=utf-8
  2 +
  3 +# @Time : 2021/6/1 9:54
  4 +# @Author : Ljq
  5 +# @File : changeCard.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 getSimpleInfo(gatewayHost=None,clientHeaders=None,cardNo=None):
  20 + """获取卡片信息"""
  21 + url = gatewayHost+f"/account-service/api/account/simpleInfo?cardNo={cardNo}"
  22 + clientHeaders=dCT.jsonCT(clientHeaders)
  23 + res = requests.get(url=url,headers=clientHeaders)
  24 + return res
  25 +
  26 +
  27 +def getChangeCardFee(gatewayHost=None,clientHeaders=None):
  28 + """获取卡片信息"""
  29 + url = gatewayHost+"/card-web/card/getChangeCardFee.action"
  30 + clientHeaders=dCT.jsonCT(clientHeaders)
  31 + res = requests.get(url=url,headers=clientHeaders)
  32 + return res
  33 +
  34 +def checkCard(gatewayHost=None,clientHeaders=None,cardNo=None,cardType=10,customerId=None):
  35 + """校验卡状态"""
  36 + url = gatewayHost+f"/card-web/cardStorage/checkCard.action?cardNo={cardNo}&cardType={cardType}&customerId={customerId}"
  37 + clientHeaders=dCT.jsonCT(clientHeaders)
  38 + res = requests.get(url=url,headers=clientHeaders)
  39 + return res
  40 +
  41 +def changeCard(gatewayHost=None,clientHeaders=None,**kwargs):
  42 + """
  43 +
  44 + :param gatewayHost:
  45 + :param clientHeaders:
  46 + :param kwargs: {"newCardNo":"888810026057","serviceFee":1000,"loginPwd":"111111",
  47 + "cardNo":"888810032426","accountId":104921,"customerId":131136}
  48 + :return:
  49 + """
  50 + url = gatewayHost+"/card-web/card/changeCard.action"
  51 + data={"newCardNo":"888810026057","serviceFee":1000,"loginPwd":"111111","cardNo":"888810032426","accountId":104921,"customerId":131136}
  52 + clientHeaders=dCT.jsonCT(clientHeaders)
  53 + data = dict(data,**kwargs)
  54 + res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data))
  55 + return res
0 \ No newline at end of file 56 \ No newline at end of file
commons/api/operatePwd.py 0 → 100644
  1 +#coding=utf-8
  2 +
  3 +# @Time : 2021/6/11 14:29
  4 +# @Author : Ljq
  5 +# @File : operatePwd.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 getSimpleInfo(gatewayHost=None,clientHeaders=None,cardNo=None):
  20 + """获取卡片信息"""
  21 + url = gatewayHost+f"/account-service/api/account/simpleInfo?cardNo={cardNo}"
  22 + clientHeaders=dCT.jsonCT(clientHeaders)
  23 + res = requests.get(url=url,headers=clientHeaders)
  24 + return res
  25 +
  26 +def modifyLoginPwd(gatewayHost=None,clientHeaders=None,**kwargs):
  27 + """获取卡片信息"""
  28 + url = gatewayHost+r"/card-web/card/modifyLoginPwd.action"
  29 + data={"oldLoginPwd":"111111","loginPwd":"111111","secondLoginPwd":"111111","cardNo":"888810032426","accountId":105339,"customerId":131136}
  30 + data = dict(data,**kwargs)
  31 + clientHeaders=dCT.jsonCT(clientHeaders)
  32 + res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data))
  33 + return res
  34 +
  35 +def resetLoginPwd(gatewayHost=None,clientHeaders=None,**kwargs):
  36 + """获取卡片信息"""
  37 + url = gatewayHost+r"/card-web/card/resetLoginPwd.action"
  38 + data={"loginPwd":"111111","secondLoginPwd":"111111","cardNo":"888810032426","accountId":105339,"customerId":131136}
  39 + data = dict(data,**kwargs)
  40 + clientHeaders=dCT.jsonCT(clientHeaders)
  41 + res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data))
  42 + return res
0 \ No newline at end of file 43 \ No newline at end of file
commons/api/returnCard.py 0 → 100644
  1 +#coding=utf-8
  2 +
  3 +# @Time : 2021/5/26 16:39
  4 +# @Author : Ljq
  5 +# @File : returnCard.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 getSimpleInfo(gatewayHost=None,clientHeaders=None,cardNo=None):
  20 + """
  21 + 获取卡信息
  22 + :param gatewayHost:
  23 + :param clientHeaders:
  24 + :param cardNo:
  25 + :return:
  26 + """
  27 + url = gatewayHost+f"/account-service/api/account/simpleInfo?cardNo={cardNo}"
  28 + res = requests.get(url=url,headers=clientHeaders)
  29 + return res
  30 +
  31 +def returnCard(gatewayHost=None,clientHeaders=None,**kwargs):
  32 + """
  33 + 退卡
  34 + :param gatewayHost:
  35 + :param clientHeaders:
  36 + :param kwargs:{"loginPwd":"111111","cardNo":"888810005703","accountId":104707,"customerId":131183}
  37 + :return:
  38 + """
  39 + url = gatewayHost+"/card-web/card/returnCard.action"
  40 + clientHeaders = dCT.jsonCT(clientHeaders)
  41 + data={"loginPwd":"111111","cardNo":"888810005703","accountId":104707,"customerId":131183}
  42 + data=dict(data,**kwargs)
  43 + # print("returnCard --- data ---> ",data)
  44 + res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data))
  45 + return res
  46 +
  47 +def returnCardDef(gatewayHost=None,clientHeaders=None,cardNo=None,loginPwd="111111"):
  48 + """
  49 + 退卡不走封装
  50 + :param gatewayHost:
  51 + :param clientHeaders:
  52 + :param cardNo:
  53 + :return:
  54 + """
  55 + # 获取卡片信息
  56 + cardInfo = getSimpleInfo(gatewayHost=gatewayHost, clientHeaders=clientHeaders, cardNo=cardNo)
  57 + # print("returnCardDef -- > cardInfo.json()",cardInfo.json())
  58 + customerId = cardInfo.json()["data"]["accountInfo"]["customerId"]
  59 + accountId = cardInfo.json()["data"]["accountInfo"]["accountId"]
  60 + # 退卡
  61 + resReturnCard = returnCard(gatewayHost=gatewayHost, clientHeaders=clientHeaders, cardNo=cardNo,
  62 + accountId=accountId, customerId=customerId,loginPwd=loginPwd)
  63 + print(resReturnCard.json())
  64 + return resReturnCard
0 \ No newline at end of file 65 \ No newline at end of file
commons/readConf.py
@@ -22,8 +22,10 @@ class readConfig(object): @@ -22,8 +22,10 @@ class readConfig(object):
22 self.file_name = r'test_config_hg' 22 self.file_name = r'test_config_hg'
23 if self.evn_name == 'nt': 23 if self.evn_name == 'nt':
24 self.relative_path = r'/config/marketConfig/' 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  
26 - # self.file_path = os.path.abspath(os.path.join(os.getcwd(), "../")) + self.relative_path+self.file_name 25 + # # 本地调试路径
  26 + # self.file_path = os.path.abspath(os.path.join(os.getcwd(), "../..")) + self.relative_path+self.file_name
  27 + # 本地main方法执行路径
  28 + self.file_path = os.path.abspath(os.path.join(os.getcwd(), "../")) + self.relative_path + self.file_name
27 elif self.evn_name == 'posix': 29 elif self.evn_name == 'posix':
28 self.relative_path = r'/config/marketConfig/' 30 self.relative_path = r'/config/marketConfig/'
29 self.file_path = os.path.abspath(os.path.join(os.getcwd())) + self.relative_path + self.file_name 31 self.file_path = os.path.abspath(os.path.join(os.getcwd())) + self.relative_path + self.file_name
config/marketConfig/test_config_hg
1 #沈阳市场信息 1 #沈阳市场信息
2 [loginInfo] 2 [loginInfo]
3 -userName=sg_wenze  
4 -password=mEVEUpWSthCXdmiXetK5TKkBEGr6kxMD0ZeFwinI/cpwC4FGk+TD6GWdKefb062UK69rGzKyLlLTxCzdFpRi1gcrG0m6erXZ+tV1I0GcvCbmQPJfn0Ha828rnbWbXS5eqKa6qOYTgZGO5tOVo0DSKMh9b/cReL7IGJ4/WF2Th8A= 3 +userName=scgy
  4 +password=DYdgRcAyx2bPboAmu0tgIYBM1kMxFAuDty7IQk4162Zh+8KKa8jtu6xIjG9W4yauTfPiuP1sqxDatskXFqCOz76ea14AqRCYEBz53xVr+vLfcz9zOB2d1T3aIlJbEk8yi2c21pd/MFkBw+Fhd0tky/6eN8kJA8mtsj3uDwSb9qo=
5 5
6 [testInfo] 6 [testInfo]
7 #已添加的身份证号 7 #已添加的身份证号
8 -cCNum=  
9 -cCNumB= 8 +cCNum=11010119990307865X
  9 +cCNumB=110101199903077593
10 #入库未开卡的卡号 10 #入库未开卡的卡号
11 -cardNum= 11 +cardNum=210607113166
12 #已开卡的卡号 12 #已开卡的卡号
13 -cardNumRe= 13 +cardNumRe=888800001207
14 #密码设置 14 #密码设置
15 loginPwd=111111 15 loginPwd=111111
16 16
practice/classA.py
@@ -17,7 +17,6 @@ class classA(object): @@ -17,7 +17,6 @@ class classA(object):
17 pass 17 pass
18 18
19 def doSomeThing(self): 19 def doSomeThing(self):
  20 + num = 1
20 print("classA.doSomeThing") 21 print("classA.doSomeThing")
21 - print(traceback.extract_stack())  
22 - print(traceback.extract_stack()[-2])  
23 - print(traceback.extract_stack()[-2][2])  
24 \ No newline at end of file 22 \ No newline at end of file
  23 + print(locals())
25 \ No newline at end of file 24 \ No newline at end of file
report/test.log
1 -[2021-07-16 16:00:54] [INFO] : 发送邮件  
2 -[2021-07-16 16:00:56] [INFO] : 邮件发送完毕 1 +[2021-07-19 10:43:38] [INFO] : 发送邮件
  2 +[2021-07-19 10:43:41] [INFO] : 邮件发送完毕
testCase/openCard/__init__.py renamed to testCase/cardSystem/__init__.py
testCase/test_addCard.py renamed to testCase/cardSystem/test_addCard.py
testCase/cardSystem/test_cardStorage.py 0 → 100644
  1 +#coding=utf-8
  2 +
  3 +# @Time : 2021/5/24 15:41
  4 +# @Author : Ljq
  5 +# @File : test_cardStorage.py
  6 +# @Software: PyCharm
  7 +
  8 +
  9 +"""
  10 + 卡片库存校验
  11 +"""
  12 +
  13 +import unittest
  14 +import requests
  15 +import time
  16 +import json
  17 +import math
  18 +import commons.api.cardStorageIn as cSI
  19 +import commons.api.cardStock as cS
  20 +import commons.api.cardStorageOut as cSO
  21 +from commons.readConf import readConfig
  22 +from commons.api.doLogin import doLogin
  23 +
  24 +class test_cardStorage(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 +
  35 + @classmethod
  36 + def tearDownClass(cls):
  37 + pass
  38 +
  39 + def setUp(self):
  40 + time.sleep(2)
  41 + # pass
  42 +
  43 + def tearDown(self):
  44 + pass
  45 +
  46 + def test_queryCardStorageList(self):
  47 + """
  48 + 库存列表测试
  49 + :return:
  50 + """
  51 + resQuery = cS.queryCardStorageList(cardHost=self.cardHost,webHeaders=self.webHeaders)
  52 + print(resQuery.json())
  53 + assert "200" == resQuery.json()["code"],"查询失败"
  54 + # 列表翻页
  55 + pageNum = math.ceil(resQuery.json()["total"]/10)
  56 + print(pageNum)
  57 + for num in range(pageNum):
  58 + resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders,page=num+1)
  59 + assert "200" == resQuery.json()["code"], "查询失败"
  60 + if num >5:
  61 + break
  62 + elif num>0:
  63 + sTime = resQuery.json()["rows"][0]["createTime"]
  64 + # print(str(num)+" sTime "+sTime)
  65 + # print(str(num) + " eTime " + eTime)
  66 + assert sTime <= eTime,"当前页第一列数据的创建时间应该小于上一页的最后一条数据的结束时间"
  67 + eTime = resQuery.json()["rows"][9]["createTime"]
  68 +
  69 + def test_cardVoid(self):
  70 + """
  71 + 作废功能测试
  72 + :return:
  73 + """
  74 + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)
  75 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3)
  76 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  77 + endCardNo = startCardNo+1
  78 + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)
  79 + # 新入库卡片作废
  80 + resVoid = cS.cardVoid(cardHost=self.cardHost,webHeaders=self.webHeaders,cardNo=startCardNo)
  81 + print(resVoid.json())
  82 + assert resVoid.json()["code"]=="200","新入库卡片作废测试失败"
  83 +
  84 + # 新出库的卡片可以作废
  85 + cardNos = str(endCardNo)
  86 + amount = 1
  87 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  88 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  89 + applyUserCode=self.applyUserCode, amount=amount)
  90 + assert outCardRes.json()["code"] == "200", "出库失败"
  91 + resVoid = cS.cardVoid(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNo=cardNos)
  92 + print(resVoid.json())
  93 + assert resVoid.json()["code"] == "200", "新出库卡片作废测试失败"
  94 +
  95 + # 已开卡的卡片不能进行作废
  96 +
  97 + def test_searchAllOptions(self):
  98 + """
  99 + 查询条件测试
  100 + :return:
  101 + """
  102 + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)
  103 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3)
  104 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  105 + endCardNo = startCardNo+6
  106 + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)
  107 +
  108 + # 新入库卡片作废
  109 + resVoid = cS.cardVoid(cardHost=self.cardHost,webHeaders=self.webHeaders,cardNo=startCardNo)
  110 + print(resVoid.json())
  111 + assert resVoid.json()["code"]=="200","新入库卡片作废测试失败"
  112 + # 卡片库存作废状态查询
  113 + resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders,cardNo=startCardNo)
  114 + assert "200" == resQuery.json()["code"], "查询失败"
  115 + assert "3" == str(resQuery.json()["rows"][0]["state"]),"状态查询成功"
  116 + # 卡片库存激活状态查询
  117 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=startCardNo+1,
  118 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  119 + applyUserCode=self.applyUserCode, amount=1)
  120 + resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNo=startCardNo+1)
  121 + assert "200" == resQuery.json()["code"], "查询失败"
  122 + assert "2" == str(resQuery.json()["rows"][0]["state"]), "状态查询成功"
  123 +
  124 + # 查询主卡
  125 + resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders, type=10)
  126 + assert "200" == resQuery.json()["code"], "查询失败"
  127 + assert 10 == list(set([i["type"] for i in resQuery.json()["rows"]]))[0], "查库存中的主卡失败"
  128 + # 查询副卡
  129 + resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders, type=20)
  130 + assert "200" == resQuery.json()["code"], "查询失败"
  131 + assert 20 == list(set([i["type"] for i in resQuery.json()["rows"]]))[0], "查库存中的副卡失败"
  132 +
  133 + # 查询卡面
  134 + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)
  135 + if len(resCardFace.json())>1:
  136 + cardFaceList = [i["value"] for i in resCardFace.json()][1:]
  137 + print(cardFaceList)
  138 + for cardFaceItem in cardFaceList:
  139 + print("1----------------------")
  140 + resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders,
  141 + cardFace=cardFaceItem)
  142 + assert 1 == len(list(set([i["cardFace"] for i in resQuery.json()["rows"]]))), "失败"
  143 + assert cardFaceItem == list(set([i["cardFace"] for i in resQuery.json()["rows"]]))[0], "卡面查询校验失败"
  144 + else:
  145 + print("2----------------------")
  146 + resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders)
  147 + assert "cardFace" not in resQuery.text, "卡面查询校验失败"
  148 +
  149 + # 卡号
  150 + resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNo=startCardNo)
  151 + # print(len(resQuery.json()["rows"]))
  152 + assert 1 == len(resQuery.json()["rows"]),"卡号查询失败"
  153 + assert str(startCardNo) == resQuery.json()["rows"][0]["cardNo"], "卡号查询失败"
  154 +
  155 + # 入库时间查询
  156 + startDate = str(time.strftime("%Y-%m-%d 00:00:00", time.localtime()))
  157 + endDate = str(time.strftime("%Y-%m-%d 23:59:59", time.localtime()))
  158 + resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders,startDate=startDate,endDate=endDate)
  159 + pageNums = math.ceil(resQuery.json()["total"]/10)
  160 + dateList = []
  161 + for pageNum in range(pageNums):
  162 + resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders,startDate=startDate,endDate=endDate,page=pageNum)
  163 + dateList = dateList+[i["createTime"] for i in resQuery.json()["rows"]]
  164 + assert [] == [i for i in dateList if i<startDate or i>endDate],"查询结果错误,查询出非当天的入库信息"
testCase/cardSystem/test_changeCard.py 0 → 100644
  1 +#coding=utf-8
  2 +
  3 +# @Time : 2021/6/1 10:02
  4 +# @Author : Ljq
  5 +# @File : test_changeCard.py
  6 +# @Software: PyCharm
  7 +
  8 +
  9 +"""
  10 +
  11 +"""
  12 +
  13 +import unittest
  14 +import requests
  15 +import time
  16 +import json
  17 +import math
  18 +import commons.api.cardStorageIn as cSI
  19 +import commons.api.returnCard as reC
  20 +import commons.api.cardStorageOut as cSO
  21 +import commons.api.openCard as oMC
  22 +import commons.api.cardStock as cS
  23 +import commons.api.changeCard as cC
  24 +from commons.readConf import readConfig
  25 +from interface.scripts.createIdNum import cIN
  26 +from commons.api.doLogin import doLogin
  27 +
  28 +class tset_changeCard(unittest.TestCase):
  29 + def setUp(self) -> None:
  30 + time.sleep(3)
  31 +
  32 + def tearDown(self) -> None:
  33 + pass
  34 +
  35 + @classmethod
  36 + def setUpClass(cls) -> None:
  37 + # 配置信息获取
  38 + readC = readConfig()
  39 + cls.cardHost = readC.returnOptionsItems("host", "cardHost")
  40 + cls.gatewayHost = readC.returnOptionsItems("host", "gatewayHost")
  41 + cls.cCNum = readC.returnOptionsItems("testInfo","cCNum")
  42 + cls.cCNumB = readC.returnOptionsItems("testInfo", "cCNumB")
  43 + cls.cardNum = readC.returnOptionsItems("testInfo", "cardNum")
  44 + cls.cardNumRe = readC.returnOptionsItems("testInfo", "cardNumRe")
  45 + cls.loginPwd = readC.returnOptionsItems("testInfo", "loginPwd")
  46 + # 登录信息获取
  47 + cls.webHeaders, cls.clientHeaders, cls.userInfo = doLogin().loginUser()
  48 + cls.applyUserName = cls.userInfo["data"]["user"]["realName"]
  49 + cls.applyUserId = cls.userInfo["data"]["user"]["id"]
  50 + cls.applyUserCode = cls.userInfo["data"]["user"]["userName"]
  51 + cls.firmId = cls.userInfo["data"]["user"]["firmId"]
  52 +
  53 + @classmethod
  54 + def tearDownClass(cls) -> None:
  55 + pass
  56 +
  57 + def test_getSimpleInfo(self):
  58 + """用户信息获取"""
  59 + # 未入库的卡片进行客户信息获取
  60 + notInCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  61 + res = cC.getSimpleInfo(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=notInCardNo)
  62 + print(res.json())
  63 + assert "10001" == res.json()["code"], "未入库的卡片进行信息获取,测试不通过"
  64 + assert "卡账户不存在" == res.json()["message"], "未入库的卡片进行信息获取,测试不通过"
  65 +
  66 + # 入库未开卡的卡片进行信息获取
  67 + faceNum = 1
  68 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  69 + endCardNo = startCardNo + 1
  70 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  71 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  72 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  73 + endCardNo=endCardNo, cardFace=cardFace)
  74 + print("resSavaCard.json() ->", resSavaCard.json())
  75 + res = cC.getSimpleInfo(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startCardNo)
  76 + print(res.json())
  77 + assert "10001" == res.json()["code"], "未出库的卡片进行信息获取,测试不通过"
  78 + assert "卡账户不存在" == res.json()["message"], "未出库的卡片进行信息获取,测试不通过"
  79 +
  80 + # 出库未开卡的卡片进行信息获取
  81 + cardNos = str(startCardNo) + "," + str(endCardNo)
  82 + print(cardNos)
  83 + amount = len([i for i in range(startCardNo, endCardNo)])
  84 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  85 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  86 + applyUserCode=self.applyUserCode, amount=amount)
  87 + assert outCardRes.json()["code"] == "200", "出库失败"
  88 + res = cC.getSimpleInfo(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startCardNo)
  89 + print(res.json())
  90 + assert "10001" == res.json()["code"], "出库未开卡的卡片进行信息获取,测试不通过"
  91 + assert "卡账户不存在" == res.json()["message"], "出库未开卡的卡片进行信息获取,测试不通过"
  92 +
  93 + # 正常的主卡获取客户信息
  94 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  95 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  96 + print("resFirstOpen", resFirstOpen.json())
  97 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  98 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  99 + res = cC.getSimpleInfo(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startCardNo)
  100 + print(res.json())
  101 + assert "200" == res.json()["code"], "正常获取客户信息获取失败"
  102 + assert "OK" == res.json()["message"], "正常获取客户信息获取失败"
  103 +
  104 + # 使用副卡进行信息获取
  105 + # 副卡入库-出库-开卡
  106 + startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  107 + endSlaveCardNo = startSlaveCardNo + 1
  108 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
  109 + endCardNo=endSlaveCardNo, cardType=20)
  110 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  111 + cardNo=startSlaveCardNo,
  112 + cardType=20)
  113 + assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
  114 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  115 + slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
  116 + amount = len([i for i in range(startSlaveCardNo, endSlaveCardNo + 1)])
  117 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
  118 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  119 + applyUserCode=self.applyUserCode, amount=amount)
  120 + assert outCardRes.json()["code"] == "200", "出库失败"
  121 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  122 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  123 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  124 + parentLoginPwd=self.loginPwd)
  125 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  126 + # 以上为测试准备
  127 + res = cC.getSimpleInfo(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startSlaveCardNo)
  128 + print(res.json())
  129 + assert "200" == res.json()["code"], "正常获取客户信息获取失败"
  130 + assert "OK" == res.json()["message"], "正常获取客户信息获取失败"
  131 +
  132 + # 已挂失的卡片进行信息获取
  133 +
  134 + # 已锁定的卡片进行信息获取
  135 +
  136 + # 已冻结的卡片进行信息获取
  137 +
  138 +
  139 + # 副卡退卡
  140 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
  141 + # 主卡退卡
  142 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  143 +
  144 +
  145 + def test_getChangeCardFee(self):
  146 + """换卡工本费信息获取"""
  147 + res = cC.getChangeCardFee(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders)
  148 + print(res.json())
  149 + assert "200" == res.json()["code"], "正常获取客户信息获取失败"
  150 + assert "OK" == res.json()["message"], "正常获取客户信息获取失败"
  151 +
  152 + def test_checkCorrectCard(self):
  153 + """新卡卡状态校验"""
  154 + # 主卡入库-出库-开卡
  155 + faceNum = 1
  156 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  157 + endCardNo = startCardNo + 1
  158 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  159 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  160 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  161 + endCardNo=endCardNo, cardFace=cardFace)
  162 + print("resSavaCard.json() ->", resSavaCard.json())
  163 + cardNos = str(startCardNo) + "," + str(endCardNo)
  164 + print(cardNos)
  165 + amount = len([i for i in range(startCardNo, endCardNo)])
  166 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  167 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  168 + applyUserCode=self.applyUserCode, amount=amount)
  169 + assert outCardRes.json()["code"] == "200", "出库失败"
  170 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  171 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  172 + print("resFirstOpen", resFirstOpen.json())
  173 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  174 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  175 + # 副卡入库-出库-开卡
  176 + startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  177 + endSlaveCardNo = startSlaveCardNo + 1
  178 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
  179 + endCardNo=endSlaveCardNo, cardType=20)
  180 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  181 + cardNo=startSlaveCardNo,
  182 + cardType=20)
  183 + assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
  184 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  185 + slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
  186 + amount = len([i for i in range(startSlaveCardNo, endSlaveCardNo + 1)])
  187 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
  188 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  189 + applyUserCode=self.applyUserCode, amount=amount)
  190 + assert outCardRes.json()["code"] == "200", "出库失败"
  191 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  192 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  193 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  194 + parentLoginPwd=self.loginPwd)
  195 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  196 + # 以上为测试数据准备
  197 +
  198 + # 主卡校验
  199 + customerId = cC.getSimpleInfo(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,
  200 + cardNo=startCardNo).json()["data"]["accountInfo"]["customerId"]
  201 + print("customerId",customerId)
  202 + resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=endCardNo,customerId=customerId)
  203 + print(resCheckCard.json())
  204 + assert "200" == resCheckCard.json()["code"], "正常新主卡校验测试不通过"
  205 + assert "OK" == resCheckCard.json()["message"], "正常新主卡校验测试不通过"
  206 + assert str(endCardNo) in resCheckCard.text, "正常新主卡校验测试不通过"
  207 +
  208 + # 副卡校验
  209 + resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=endSlaveCardNo,cardType=20,customerId=customerId)
  210 + print(resCheckCard.json())
  211 + assert "200" == resCheckCard.json()["code"], "正常新副卡校验测试不通过"
  212 + assert "OK" == resCheckCard.json()["message"], "正常新副卡校验测试不通过"
  213 + assert str(endSlaveCardNo) in resCheckCard.text, "正常新副卡校验测试不通过"
  214 +
  215 + # 副卡退卡
  216 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
  217 + # 主卡退卡
  218 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  219 +
  220 + def test_checkErrorCard(self):
  221 + """使用错误状态的卡片进行新卡校验"""
  222 + # 主卡入库-出库-开卡
  223 + faceNum = 1
  224 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  225 + endCardNo = startCardNo + 2
  226 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  227 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  228 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  229 + endCardNo=endCardNo, cardFace=cardFace)
  230 + print("resSavaCard.json() ->", resSavaCard.json())
  231 + cardNos = str(startCardNo) + "," + str(endCardNo)
  232 + print(cardNos)
  233 + amount = 2
  234 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  235 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  236 + applyUserCode=self.applyUserCode, amount=amount)
  237 + assert outCardRes.json()["code"] == "200", "出库失败"
  238 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  239 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  240 + print("resFirstOpen", resFirstOpen.json())
  241 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  242 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  243 + # 副卡入库-出库-开卡
  244 + startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  245 + endSlaveCardNo = startSlaveCardNo + 2
  246 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
  247 + endCardNo=endSlaveCardNo, cardType=20)
  248 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  249 + cardNo=startSlaveCardNo,
  250 + cardType=20)
  251 + assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
  252 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  253 + slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
  254 + amount = 2
  255 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
  256 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  257 + applyUserCode=self.applyUserCode, amount=amount)
  258 + assert outCardRes.json()["code"] == "200", "出库失败"
  259 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  260 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  261 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  262 + parentLoginPwd=self.loginPwd)
  263 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  264 + # 开卡结束
  265 +
  266 + customerId = cC.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  267 + cardNo=startCardNo).json()["data"]["accountInfo"]["customerId"]
  268 + print("customerId", customerId)
  269 + # 以上为测试数据准备
  270 +
  271 + """开始测试"""
  272 + # 使用未出库的卡片进行校验
  273 + resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=999999999999,
  274 + customerId=customerId)
  275 + print("resCheckCard",resCheckCard.json())
  276 + assert "10000" == resCheckCard.json()["code"], "未入库卡片校验测试不通过"
  277 + assert "该卡未入库!" == resCheckCard.json()["message"], "未入库卡片校验测试不通过"
  278 +
  279 + # 使用已作废的卡片进行校验
  280 + voidCardNo = startCardNo+1
  281 + resVoid = cS.cardVoid(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNo=voidCardNo)
  282 + assert resVoid.json()["code"] == "200", "新入库卡片作废测试失败"
  283 + resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=voidCardNo,
  284 + customerId=customerId)
  285 + print("resCheckCard",resCheckCard.json())
  286 + assert "20000" == resCheckCard.json()["code"], "[作废]卡片校验测试不通过"
  287 + assert "该卡状态为[作废],不能开卡!" == resCheckCard.json()["message"], "[作废]卡片校验测试不通过"
  288 +
  289 + # 使用不匹配的卡面进行校验 -- 寿光市场
  290 + if self.firmId == 8:
  291 + pass
  292 +
  293 + # 使用已开卡的主卡进行校验
  294 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  295 + cCNum=self.cCNum, cardNo=endCardNo, applyUserName=self.applyUserName)
  296 + print("resFirstOpen", resFirstOpen.json())
  297 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  298 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  299 + resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endCardNo,
  300 + customerId=customerId)
  301 + # print("resCheckCard",resCheckCard.json())
  302 + assert "20000" == resCheckCard.json()["code"], "正常新主卡校验测试不通过"
  303 + assert "该卡状态为[在用],不能开卡!" == resCheckCard.json()["message"], "正常新主卡校验测试不通过"
  304 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endCardNo) #退卡
  305 + resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endCardNo,
  306 + customerId=customerId)
  307 +
  308 + # 使用已退还的卡片可以进行换卡操作校验成功
  309 + # print("resCheckCard",resCheckCard.json())
  310 + assert "200" == resCheckCard.json()["code"], "已退还的主卡校验测试不通过"
  311 + assert "OK" == resCheckCard.json()["message"], "已退还的主卡校验测试不通过"
  312 + assert str(endCardNo) in resCheckCard.text, "已退还的主卡校验测试不通过"
  313 +
  314 + # 主卡换卡时使用副卡校验
  315 + resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardType=10,cardNo=endSlaveCardNo,
  316 + customerId=customerId)
  317 + print("resCheckCard",resCheckCard.json())
  318 + assert "20000" == resCheckCard.json()["code"], "使用副卡对主卡进行换卡校验测试不通过"
  319 + assert "请使用主卡办理当前业务!" == resCheckCard.json()["message"], "使用副卡对主卡进行换卡校验测试不通过"
  320 +
  321 + # 副卡换卡时使用主卡进行校验
  322 + resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardType=20,cardNo=endCardNo,
  323 + customerId=customerId)
  324 + print("resCheckCard",resCheckCard.json())
  325 + assert "20000" == resCheckCard.json()["code"], "副卡换卡时使用主卡进行校验测试不通过"
  326 + assert "请使用副卡办理当前业务!" == resCheckCard.json()["message"], "副卡换卡时使用主卡进行校验测试不通过"
  327 +
  328 + # 使用未出库的副卡进行校验
  329 + resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  330 + cardNo=999999999999, cardType=20, customerId=customerId)
  331 + print(resCheckCard.json())
  332 + assert "10000" == resCheckCard.json()["code"], "未入库卡片校验测试不通过"
  333 + assert "该卡未入库!" == resCheckCard.json()["message"], "未入库卡片校验测试不通过"
  334 +
  335 + # 使用已开卡的副卡进行校验
  336 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  337 + cardNo=startCardNo, slaveCardNo=endSlaveCardNo,
  338 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  339 + parentLoginPwd=self.loginPwd)
  340 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  341 + resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  342 + cardNo=endSlaveCardNo, cardType=20, customerId=customerId)
  343 + print(resCheckCard.json())
  344 + assert "20000" == resCheckCard.json()["code"], "已开卡的卡片进行状态校验测试不通过"
  345 + assert "该卡状态为[在用],不能开卡!" == resCheckCard.json()["message"], "已开卡的卡片进行状态校验测试不通过"
  346 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endSlaveCardNo)
  347 +
  348 + """测试完成"""
  349 + # 副卡退卡
  350 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
  351 + # 主卡退卡
  352 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  353 +
  354 + def test_changeCard(self):
  355 + """换卡正向流程测试"""
  356 + # 主卡入库-出库-开卡
  357 + faceNum = 1
  358 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  359 + endCardNo = startCardNo + 2
  360 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  361 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  362 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  363 + endCardNo=endCardNo, cardFace=cardFace)
  364 + print("resSavaCard.json() ->", resSavaCard.json())
  365 + cardNos = str(startCardNo) + "," + str(endCardNo)
  366 + amount = 2
  367 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  368 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  369 + applyUserCode=self.applyUserCode, amount=amount)
  370 + assert outCardRes.json()["code"] == "200", "出库失败"
  371 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  372 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  373 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  374 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  375 + # 副卡入库-出库-开卡
  376 + startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  377 + endSlaveCardNo = startSlaveCardNo + 2
  378 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
  379 + endCardNo=endSlaveCardNo, cardType=20)
  380 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  381 + cardNo=startSlaveCardNo,
  382 + cardType=20)
  383 + assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
  384 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  385 + slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
  386 + amount = 2
  387 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
  388 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  389 + applyUserCode=self.applyUserCode, amount=amount)
  390 + assert outCardRes.json()["code"] == "200", "出库失败"
  391 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  392 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  393 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  394 + parentLoginPwd=self.loginPwd)
  395 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  396 + # 开卡结束 --- > 获取卡账户信息,换卡工本费
  397 + serviceFee = cC.getChangeCardFee(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders).json()["data"]
  398 + # 以上为测试数据准备
  399 + """开始测试"""
  400 +
  401 + # 主卡换卡正常换卡测试 ---> 换卡成功后原卡片变为激活状态
  402 + resSimpleInfo = cC.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  403 + cardNo=startCardNo)
  404 + customerId,accountId = resSimpleInfo.json()["data"]["accountInfo"]["customerId"],resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
  405 + resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startCardNo,
  406 + newCardNo=endCardNo,serviceFee=serviceFee,loginPwd=self.loginPwd,accountId=accountId,customerId=customerId)
  407 + assert "200" == resChangeCard.json()["code"],"主卡换卡测试不通过"
  408 + assert "OK" == resChangeCard.json()["message"],"主卡换卡测试不通过"
  409 + resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders,cardNo=startCardNo)
  410 + assert "200" == resQuery.json()["code"], "查询失败"
  411 + assert "2" == str(resQuery.json()["rows"][0]["state"]),"状态查询成功"
  412 +
  413 + # 副卡换卡正常换卡测试,换卡成功后原卡片变为激活状态
  414 + resSimpleInfo = cC.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  415 + cardNo=startSlaveCardNo)
  416 + customerId,accountId = resSimpleInfo.json()["data"]["accountInfo"]["customerId"],resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
  417 + resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  418 + cardNo=startSlaveCardNo,
  419 + newCardNo=endSlaveCardNo, serviceFee=serviceFee, loginPwd=self.loginPwd,
  420 + accountId=accountId, customerId=customerId)
  421 + assert "200" == resChangeCard.json()["code"], "主卡换卡测试不通过"
  422 + assert "OK" == resChangeCard.json()["message"], "主卡换卡测试不通过"
  423 + resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNo=startSlaveCardNo)
  424 + assert "200" == resQuery.json()["code"], "查询失败"
  425 + assert "2" == str(resQuery.json()["rows"][0]["state"]), "状态查询成功"
  426 +
  427 +
  428 + """测试完成"""
  429 + # 副卡退卡
  430 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endSlaveCardNo)
  431 + # 主卡退卡
  432 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endCardNo)
  433 +
  434 + def test_changeCardError(self):
  435 + """换卡正向流程测试"""
  436 + # 主卡入库-出库-开卡
  437 + faceNum = 1
  438 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  439 + endCardNo = startCardNo + 2
  440 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  441 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  442 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  443 + endCardNo=endCardNo, cardFace=cardFace)
  444 + print("resSavaCard.json() ->", resSavaCard.json())
  445 + cardNos = str(startCardNo) + "," + str(endCardNo)
  446 + amount = 2
  447 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  448 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  449 + applyUserCode=self.applyUserCode, amount=amount)
  450 + assert outCardRes.json()["code"] == "200", "出库失败"
  451 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  452 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  453 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  454 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  455 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  456 + cCNum=self.cCNum, cardNo=endCardNo, applyUserName=self.applyUserName)
  457 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  458 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  459 + # 副卡入库-出库-开卡
  460 + startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  461 + endSlaveCardNo = startSlaveCardNo + 2
  462 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
  463 + endCardNo=endSlaveCardNo, cardType=20)
  464 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  465 + cardNo=startSlaveCardNo,
  466 + cardType=20)
  467 + assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
  468 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  469 + slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
  470 + amount = 2
  471 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
  472 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  473 + applyUserCode=self.applyUserCode, amount=amount)
  474 + assert outCardRes.json()["code"] == "200", "出库失败"
  475 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  476 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  477 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  478 + parentLoginPwd=self.loginPwd)
  479 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  480 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  481 + cardNo=startCardNo, slaveCardNo=endSlaveCardNo,
  482 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  483 + parentLoginPwd=self.loginPwd)
  484 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  485 + # 开卡结束 --- > 获取卡账户信息,换卡工本费
  486 + serviceFee = cC.getChangeCardFee(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders).json()["data"]
  487 + resSimpleInfo = cC.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  488 + cardNo=startCardNo)
  489 + customerId,accountId = resSimpleInfo.json()["data"]["accountInfo"]["customerId"],resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
  490 + resSimpleInfo = cC.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  491 + cardNo=startSlaveCardNo)
  492 + customerIdSlaveCard,accountIdSlaveCard = resSimpleInfo.json()["data"]["accountInfo"]["customerId"],resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
  493 + # 以上为测试数据准备
  494 + """开始测试"""
  495 +
  496 + # 使用未入库的主卡卡片和副卡进行换卡
  497 + resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startCardNo,
  498 + newCardNo=999999999999,serviceFee=serviceFee,loginPwd=self.loginPwd,accountId=accountId,customerId=customerId)
  499 + assert "10000" == resChangeCard.json()["code"],"主卡换卡测试不通过"
  500 + assert "该卡未入库!" == resChangeCard.json()["message"],"主卡换卡测试不通过"
  501 + resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startSlaveCardNo,
  502 + newCardNo=999999999999,serviceFee=serviceFee,loginPwd=self.loginPwd,
  503 + accountId=accountIdSlaveCard,customerId=customerIdSlaveCard)
  504 + assert "10000" == resChangeCard.json()["code"],"副卡换卡测试不通过"
  505 + assert "该卡未入库!" == resChangeCard.json()["message"],"副卡换卡测试不通过"
  506 +
  507 + # 使用未出库的主卡卡片和副卡进行换卡
  508 + resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startCardNo,
  509 + newCardNo=startCardNo+1,serviceFee=serviceFee,loginPwd=self.loginPwd,accountId=accountId,customerId=customerId)
  510 + print(resChangeCard.json())
  511 + assert "20000" == resChangeCard.json()["code"],"使用未出库的主卡换卡测试不通过"
  512 + assert "该卡状态为[未激活],不能开卡!" == resChangeCard.json()["message"],"使用未出库的主卡换卡测试不通过"
  513 + resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startSlaveCardNo,
  514 + newCardNo=startSlaveCardNo+1,serviceFee=serviceFee,loginPwd=self.loginPwd,
  515 + accountId=accountIdSlaveCard,customerId=customerIdSlaveCard)
  516 + print(resChangeCard.json())
  517 + assert "20000" == resChangeCard.json()["code"],"使用未出库的副卡换卡测试不通过"
  518 + assert "该卡状态为[未激活],不能开卡!" == resChangeCard.json()["message"],"使用未出库的副卡换卡测试不通过"
  519 +
  520 + # 使用已开卡的主卡卡片和副卡进行换卡
  521 + resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  522 + cardNo=startCardNo,
  523 + newCardNo=endCardNo, serviceFee=serviceFee, loginPwd=self.loginPwd,
  524 + accountId=accountId, customerId=customerId)
  525 + print(resChangeCard.json())
  526 + assert "20000" == resChangeCard.json()["code"], "主卡换卡测试不通过"
  527 + assert "该卡状态为[在用],不能开卡!" == resChangeCard.json()["message"], " 使用已开卡的主卡换卡测试不通过"
  528 + resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  529 + cardNo=startSlaveCardNo,
  530 + newCardNo=endSlaveCardNo, serviceFee=serviceFee, loginPwd=self.loginPwd,
  531 + accountId=accountIdSlaveCard, customerId=customerIdSlaveCard)
  532 + print(resChangeCard.json())
  533 + assert "20000" == resChangeCard.json()["code"], "副卡换卡测试不通过"
  534 + assert "该卡状态为[在用],不能开卡!" == resChangeCard.json()["message"], " 使用已开卡的副卡换卡测试不通过"
  535 +
  536 + """测试完成"""
  537 + # 副卡退卡
  538 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endSlaveCardNo)
  539 + # 副卡退卡
  540 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
  541 + # 主卡退卡
  542 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endCardNo)
  543 + # 主卡退卡
  544 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  545 +
testCase/cardSystem/test_lossCard.py 0 → 100644
  1 +#coding=utf-8
  2 +
  3 +# @Time : 2021/6/17 15:56
  4 +# @Author : Ljq
  5 +# @File : test_lossCard.py
  6 +# @Software: PyCharm
  7 +
  8 +
  9 +"""
  10 +
  11 +"""
  12 +
  13 +import unittest
  14 +import requests
  15 +import time
  16 +import json
  17 +import math
  18 +import commons.api.cardStorageIn as cardStorageIn
  19 +import commons.api.returnCard as returnCard
  20 +import commons.api.cardStorageOut as cardStorageOut
  21 +import commons.api.openCard as openCard
  22 +import commons.api.cardLostAndUnLost as cardLostAndUnLost
  23 +from commons.readConf import readConfig
  24 +from commons.api.doLogin import doLogin
  25 +
  26 +class test_lossCardAndUn(unittest.TestCase):
  27 + """卡片挂失,解挂测试"""
  28 + def setUp(self) -> None:
  29 + # 主卡入库-出库-开卡
  30 + faceNum = 1
  31 + self.startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  32 + self.endCardNo = self.startCardNo + 2
  33 + resCardFace = cardStorageIn.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  34 + cardFace = cardStorageIn.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  35 + resSavaCard = cardStorageIn.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders,
  36 + startCardNo=self.startCardNo,
  37 + endCardNo=self.endCardNo, cardFace=cardFace)
  38 + print("resSavaCard.json() ->", resSavaCard.json())
  39 + cardNos = str(self.startCardNo) + "," + str(self.endCardNo)
  40 + print(cardNos)
  41 + amount = 2
  42 + outCardRes = cardStorageOut.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  43 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  44 + applyUserCode=self.applyUserCode, amount=amount)
  45 + assert outCardRes.json()["code"] == "200", "出库失败"
  46 + resFirstOpen = openCard.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  47 + cCNum=self.cCNum, cardNo=self.startCardNo,
  48 + applyUserName=self.applyUserName)
  49 + print("resFirstOpen", resFirstOpen.json())
  50 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  51 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  52 + # 副卡入库-出库-开卡
  53 + self.startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  54 + self.endSlaveCardNo = self.startSlaveCardNo + 2
  55 + resSavaCard = cardStorageIn.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders,
  56 + startCardNo=self.startSlaveCardNo,
  57 + endCardNo=self.endSlaveCardNo, cardType=20)
  58 + res = openCard.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  59 + cardNo=self.startSlaveCardNo,
  60 + cardType=20)
  61 + assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
  62 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  63 + slaveCardNos = str(self.startSlaveCardNo) + "," + str(self.endSlaveCardNo)
  64 + amount = 2
  65 + outCardRes = cardStorageOut.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
  66 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  67 + applyUserCode=self.applyUserCode, amount=amount)
  68 + assert outCardRes.json()["code"] == "200", "出库失败"
  69 + resOpenSlaveCard = openCard.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  70 + cardNo=self.startCardNo, slaveCardNo=self.startSlaveCardNo,
  71 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  72 + parentLoginPwd=self.loginPwd)
  73 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  74 + # 开卡结束-获取卡片客户信息
  75 +
  76 + def tearDown(self) -> None:
  77 + # 副卡退卡,主卡退卡
  78 + returnCard.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  79 + cardNo=self.startSlaveCardNo)
  80 + returnCard.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=self.startCardNo)
  81 +
  82 + @classmethod
  83 + def setUpClass(cls) -> None:
  84 + # 配置信息获取
  85 + readC = readConfig()
  86 + cls.cardHost = readC.returnOptionsItems("host", "cardHost")
  87 + cls.gatewayHost = readC.returnOptionsItems("host", "gatewayHost")
  88 + cls.cCNum = readC.returnOptionsItems("testInfo","cCNum")
  89 + cls.cCNumB = readC.returnOptionsItems("testInfo", "cCNumB")
  90 + cls.cardNum = readC.returnOptionsItems("testInfo", "cardNum")
  91 + cls.cardNumRe = readC.returnOptionsItems("testInfo", "cardNumRe")
  92 + cls.loginPwd = readC.returnOptionsItems("testInfo", "loginPwd")
  93 + # 登录信息获取
  94 + cls.webHeaders, cls.clientHeaders, cls.userInfo = doLogin().loginUser()
  95 + cls.applyUserName = cls.userInfo["data"]["user"]["realName"]
  96 + cls.applyUserId = cls.userInfo["data"]["user"]["id"]
  97 + cls.applyUserCode = cls.userInfo["data"]["user"]["userName"]
  98 + cls.firmId = cls.userInfo["data"]["user"]["firmId"]
  99 +
  100 + @classmethod
  101 + def tearDownClass(cls) -> None:
  102 + pass
  103 +
  104 + def test_getAccountInfo(self):
  105 + """
  106 + 获取卡片信息测试
  107 + :return:
  108 + """
  109 + # 使用未入库的卡片进行获取
  110 + resGet = openCard.getAccountInfo(gatewayHost=self.gatewayHost,clientHeaders =self.clientHeaders,cardNo=999999999999)
  111 + print(resGet.json())
  112 + assert "10001" == resGet.json()["code"],"未入库卡片信息获取测试不通过"
  113 + assert "卡账户不存在" == resGet.json()["message"],"未入库卡片信息获取测试不通过"
  114 +
  115 + # 使用入库未出库的卡片进行信息获取
  116 + # 卡片入库
  117 + faceNum = 1
  118 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  119 + endCardNo = startCardNo + 2
  120 +
  121 + resCardFace = cardStorageIn.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  122 + cardFace = cardStorageIn.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  123 + resSavaCard = cardStorageIn.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  124 + endCardNo=endCardNo, cardFace=cardFace)
  125 + resGet = openCard.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  126 + print(resGet.json())
  127 + assert "10001" == resGet.json()["code"], "未出库卡片信息获取测试不通过"
  128 + assert "卡账户不存在" == resGet.json()["message"], "未出库卡片信息获取测试不通过"
  129 +
  130 + # 使用出库未开卡的卡片进行信息获取
  131 + cardNos = str(startCardNo) + "," + str(endCardNo)
  132 + amount = len([i for i in range(startCardNo, endCardNo + 1)])
  133 + outCardRes = cardStorageOut.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  134 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  135 + applyUserCode=self.applyUserCode, amount=amount)
  136 + assert outCardRes.json()["code"] == "200", "出库失败"
  137 + resGet = openCard.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  138 + print(resGet.json())
  139 + assert "10001" == resGet.json()["code"], "未出库卡片信息获取测试不通过"
  140 + assert "卡账户不存在" == resGet.json()["message"], "未出库卡片信息获取测试不通过"
  141 +
  142 + # 使用已开卡的卡片可以正确的获取到客户信息
  143 + resFirstOpen = openCard.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  144 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  145 + assert "200" == resFirstOpen.json()["code"], "开卡失败"
  146 + assert "data" in resFirstOpen.json(), "开卡失败"
  147 + resGet = openCard.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  148 + # print("resGet.json()",resGet.json())
  149 + assert "200" == resGet.json()["code"], "已开卡卡片信息获取测试不通过"
  150 + assert "data" in resGet.json(), "已开卡卡片信息获取测试不通过"
  151 +
  152 + # 使用已挂失的卡片信息进行卡片信息获取
  153 + accountId,customerId = resGet.json()["data"]["accountId"],resGet.json()["data"]["customerId"]
  154 + resLossCard = cardLostAndUnLost.lossCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=str(startCardNo),
  155 + accountId=accountId, customerId=customerId, loginPwd=self.loginPwd)
  156 + # print("resLossCard.json()",resLossCard.json())
  157 + assert "200" == resLossCard.json()["code"],"已挂失的卡片获取卡片信息测试不通过"
  158 + resGet = openCard.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  159 + # print("resGet.json()", resGet.json())
  160 + assert "2000" == resGet.json()["code"], "未出库卡片信息获取测试不通过"
  161 + assert "该卡为挂失状态,不能进行此操作" == resGet.json()["message"], "未出库卡片信息获取测试不通过"
  162 + # 解挂
  163 + resUnLoss = cardLostAndUnLost.unLostCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=str(startCardNo),
  164 + accountId=accountId, customerId=customerId, loginPwd=self.loginPwd)
  165 + # print("resUnLoss.json()",resUnLoss.json())
  166 +
  167 + # 账号冻结状态
  168 +
  169 + # 卡片锁定状态
  170 +
  171 + # 使用已退还的卡片进行卡片信息获取
  172 + returnCard.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  173 + resGet = openCard.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  174 + # print("resGet.json()", resGet.json())
  175 + assert "2000" == resGet.json()["code"], "已退还的卡片信息获取测试不通过"
  176 + assert "该卡为退还状态,不能进行此操作" == resGet.json()["message"], "已退还的卡片信息获取测试不通过"
  177 +
  178 +
  179 + def test_lossCardAndUnLost(self):
  180 + """卡片挂失"""
  181 + # 获取卡片客户信息
  182 + accountInfo = openCard.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=self.startCardNo)
  183 + accountId,customerId = accountInfo.json()["data"]["accountId"],accountInfo.json()["data"]["customerId"]
  184 + slaveCardAccountInfo = openCard.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=self.startSlaveCardNo)
  185 + print("slaveCardAccountInfo ",slaveCardAccountInfo.json())
  186 + customerIdSlaveCard, accountIdSlaveCard = slaveCardAccountInfo.json()["data"]["customerId"], slaveCardAccountInfo.json()["data"]["accountId"]
  187 + # 以上为测试数据准备
  188 +
  189 + """开始测试"""
  190 + # 正常主卡卡片挂失解挂
  191 + resLossCard = cardLostAndUnLost.lossCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  192 + cardNo=str(self.startCardNo),accountId=accountId, customerId=customerId,
  193 + loginPwd=self.loginPwd)
  194 + assert "200" == resLossCard.json()["code"],"卡片挂失失败"
  195 + resUnLoss = cardLostAndUnLost.unLostCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  196 + cardNo=str(self.startCardNo), accountId=accountId, customerId=customerId,
  197 + loginPwd=self.loginPwd)
  198 + assert "200" == resUnLoss.json()["code"],"卡片解挂失败"
  199 +
  200 +
  201 + # 正常副卡卡片挂失解挂
  202 + resLossCard = cardLostAndUnLost.lossCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  203 + cardNo=str(self.startSlaveCardNo),accountId=accountIdSlaveCard,
  204 + customerId=customerIdSlaveCard,
  205 + loginPwd=self.loginPwd)
  206 + assert "200" == resLossCard.json()["code"],"副卡挂失失败"
  207 + resUnLoss = cardLostAndUnLost.unLostCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  208 + cardNo=str(self.startSlaveCardNo), accountId=accountIdSlaveCard,
  209 + customerId=customerIdSlaveCard,
  210 + loginPwd=self.loginPwd)
  211 + assert "200" == resUnLoss.json()["code"], "副卡解挂失败"
  212 +
  213 + """测试完成"""
  214 +
  215 + def test_lossCardError(self):
  216 + """挂失卡片异常情况"""
  217 + # 卡账户信息准备
  218 + accountInfo = openCard.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  219 + cardNo=self.startCardNo)
  220 + accountId, customerId = accountInfo.json()["data"]["accountId"], accountInfo.json()["data"]["customerId"]
  221 + slaveCardAccountInfo = openCard.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  222 + cardNo=self.startSlaveCardNo)
  223 + print("slaveCardAccountInfo ", slaveCardAccountInfo.json())
  224 + customerIdSlaveCard, accountIdSlaveCard = slaveCardAccountInfo.json()["data"]["customerId"], \
  225 + slaveCardAccountInfo.json()["data"]["accountId"]
  226 + # 以上为测试数据准备
  227 +
  228 + """开始测试"""
  229 + # 密码长度不满足六位数字时挂失失败
  230 + resLossCard = cardLostAndUnLost.lossCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  231 + cardNo=str(self.startCardNo), accountId=accountId, customerId=customerId,
  232 + loginPwd="1111111")
  233 + assert "1000" == resLossCard.json()["code"], "密码长度超过六位的错误验证测试不通过"
  234 + assert "密码必须6位" == resLossCard.json()["message"], "密码长度超过六位的错误验证测试不通过"
  235 + resLossCard = cardLostAndUnLost.lossCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  236 + cardNo=str(self.startCardNo), accountId=accountId, customerId=customerId,
  237 + loginPwd="11111")
  238 + assert "1000" == resLossCard.json()["code"], "密码长度不足六位的错误验证测试不通过"
  239 + assert "密码必须6位" == resLossCard.json()["message"], "密码长度不足六位的错误验证测试不通过"
  240 +
  241 + # 密码错误挂失失败
  242 + resLossCard = cardLostAndUnLost.lossCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  243 + cardNo=str(self.startCardNo), accountId=accountId, customerId=customerId,
  244 + loginPwd="123890")
  245 + assert "10001" == resLossCard.json()["code"], "密码错误挂失失败测试不通过"
  246 + assert "密码输入有误" == resLossCard.json()["message"], "密码错误挂失失败测试不通过"
  247 +
  248 +
  249 + # 主卡挂失后,副卡不可以再进行挂失
  250 + resLossCard = cardLostAndUnLost.lossCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  251 + cardNo=str(self.startCardNo), accountId=accountId, customerId=customerId,
  252 + loginPwd=self.loginPwd)
  253 + assert "200" == resLossCard.json()["code"], "卡片挂失失败"
  254 + resLossCard = cardLostAndUnLost.lossCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  255 + cardNo=str(self.startSlaveCardNo), accountId=accountIdSlaveCard,
  256 + customerId=customerIdSlaveCard,
  257 + loginPwd=self.loginPwd)
  258 + assert "2000" == resLossCard.json()["code"], "主卡挂失后副卡不能挂失测试失败"
  259 + assert f"该卡的主卡【{self.startCardNo}】为挂失状态,不能进行此操作" == resLossCard.json()["message"], "主卡挂失后副卡不能挂失测试失败"
  260 + resUnLoss = cardLostAndUnLost.unLostCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  261 + cardNo=str(self.startCardNo), accountId=accountId, customerId=customerId,
  262 + loginPwd=self.loginPwd)
  263 + assert "200" == resUnLoss.json()["code"], "卡片解挂失败"
  264 + """测试完成"""
  265 +
  266 + def test_getByCardForUnLost(self):
  267 + """挂失卡片信息信息"""
  268 + # 卡账户信息准备
  269 + accountInfo = openCard.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  270 + cardNo=self.startCardNo)
  271 + accountId, customerId = accountInfo.json()["data"]["accountId"], accountInfo.json()["data"]["customerId"]
  272 + slaveCardAccountInfo = openCard.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  273 + cardNo=self.startSlaveCardNo)
  274 + print("slaveCardAccountInfo ", slaveCardAccountInfo.json())
  275 + customerIdSlaveCard, accountIdSlaveCard = slaveCardAccountInfo.json()["data"]["customerId"], \
  276 + slaveCardAccountInfo.json()["data"]["accountId"]
  277 + # 以上为测试数据准备
  278 +
  279 + """开始测试"""
  280 +
  281 + # 使用状态正常的卡片进行信息获取
  282 + resGetByCard = cardLostAndUnLost.getByCardForUnLost(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  283 + cardNo=self.startCardNo)
  284 + print(resGetByCard.json())
  285 + assert "2000" == resGetByCard.json()["code"],"状态正常的卡片用户信息获取测试不通过"
  286 + assert "该卡为正常状态,不能进行此操作" == resGetByCard.json()["message"],"状态正常的卡片用户信息获取测试不通过"
  287 +
  288 + # 已挂失的卡片可以成功获取到卡片信息
  289 + resLossCard = cardLostAndUnLost.lossCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  290 + cardNo=str(self.startCardNo), accountId=accountId, customerId=customerId,
  291 + loginPwd=self.loginPwd)
  292 + assert "200" == resLossCard.json()["code"], "卡片挂失失败"
  293 +
  294 + resGetByCard = cardLostAndUnLost.getByCardForUnLost(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  295 + cardNo=self.startCardNo)
  296 + print(resGetByCard.json())
  297 + assert "200" == resGetByCard.json()["code"],"已挂失的卡片可以成功获取到卡片信息测试不通过"
  298 + assert f"{accountId}" in resGetByCard.text,"已挂失的卡片可以成功获取到卡片信息测试不通过"
  299 +
  300 + resUnLoss = cardLostAndUnLost.unLostCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  301 + cardNo=str(self.startCardNo), accountId=accountId, customerId=customerId,
  302 + loginPwd=self.loginPwd)
  303 + assert "200" == resUnLoss.json()["code"], "卡片解挂失败"
  304 +
  305 + # 未开卡的卡片获取信息验证
  306 + resGetByCard = cardLostAndUnLost.getByCardForUnLost(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  307 + cardNo="999999999999")
  308 + print(resGetByCard.json())
  309 + assert "10001" == resGetByCard.json()["code"],"未开卡的卡片获取信息验证测试不通过"
  310 + assert "卡账户不存在" == resGetByCard.json()["message"],"未开卡的卡片获取信息验证测试不通过"
  311 +
  312 + # 副卡挂失操作异常操作
  313 + print("开始副卡挂失异常操作")
  314 +
  315 + # 使用状态正常的副卡进行信息获取
  316 + resGetByCard = cardLostAndUnLost.getByCardForUnLost(gatewayHost=self.gatewayHost,
  317 + clientHeaders=self.clientHeaders,
  318 + cardNo=self.startSlaveCardNo)
  319 + print(resGetByCard.json())
  320 + assert "2000" == resGetByCard.json()["code"], "状态正常的副卡用户信息获取测试不通过"
  321 + assert "该卡为正常状态,不能进行此操作" == resGetByCard.json()["message"], "状态正常的副卡用户信息获取测试不通过"
  322 +
  323 + # 已挂失的副卡可以正常查询
  324 + resLossCard = cardLostAndUnLost.lossCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  325 + cardNo=str(self.startSlaveCardNo), accountId=accountIdSlaveCard,
  326 + customerId=customerIdSlaveCard,
  327 + loginPwd=self.loginPwd)
  328 + assert "200" == resLossCard.json()["code"], "副卡挂失失败"
  329 + resGetByCard = cardLostAndUnLost.getByCardForUnLost(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  330 + cardNo=self.startSlaveCardNo)
  331 + assert "200" == resGetByCard.json()["code"],"已挂失的副卡可以正常查询测试不通过"
  332 + assert f"{accountId}" in resGetByCard.text,"已挂失的副卡可以正常查询测试不通过"
  333 +
  334 + # 副卡解挂
  335 + resUnLoss = cardLostAndUnLost.unLostCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  336 + cardNo=str(self.startSlaveCardNo), accountId=accountIdSlaveCard,
  337 + customerId=customerIdSlaveCard,
  338 + loginPwd=self.loginPwd)
  339 + assert "200" == resUnLoss.json()["code"], "副卡解挂失败"
  340 + """测试完成"""
  341 +
  342 +
  343 + def test_unLostError(self):
  344 + """卡片异常解挂"""
  345 + # 卡账户信息准备
  346 + accountInfo = openCard.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  347 + cardNo=self.startCardNo)
  348 + accountId, customerId = accountInfo.json()["data"]["accountId"], accountInfo.json()["data"]["customerId"]
  349 + slaveCardAccountInfo = openCard.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  350 + cardNo=self.startSlaveCardNo)
  351 + print("slaveCardAccountInfo ", slaveCardAccountInfo.json())
  352 + customerIdSlaveCard, accountIdSlaveCard = slaveCardAccountInfo.json()["data"]["customerId"], \
  353 + slaveCardAccountInfo.json()["data"]["accountId"]
  354 + resLossCard = cardLostAndUnLost.lossCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  355 + cardNo=str(self.startCardNo), accountId=accountId,
  356 + customerId=customerId,
  357 + loginPwd=self.loginPwd)
  358 + assert "200" == resLossCard.json()["code"], "卡片挂失失败"
  359 + resGetByCard = cardLostAndUnLost.getByCardForUnLost(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  360 + cardNo=self.startCardNo)
  361 + assert "200" == resGetByCard.json()["code"],"已挂失的卡片可以成功获取到卡片信息测试不通过"
  362 +
  363 + """开始测试"""
  364 + # 使用错误的密码进行解挂
  365 + resUnLoss = cardLostAndUnLost.unLostCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  366 + cardNo=str(self.startCardNo), accountId=accountId,
  367 + customerId=customerId,
  368 + loginPwd="123890")
  369 + print("resUnLoss",resUnLoss.json())
  370 + assert "10001" == resUnLoss.json()["code"], "使用错误的密码解挂失败测试不通过"
  371 + assert "密码输入有误" == resUnLoss.json()["message"], "使用错误的密码解挂失败测试不通过"
  372 +
  373 + # 小于六位的密码进行解挂
  374 + resUnLoss = cardLostAndUnLost.unLostCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  375 + cardNo=str(self.startCardNo), accountId=accountId,
  376 + customerId=customerId,
  377 + loginPwd="123")
  378 + print("resUnLoss",resUnLoss.json())
  379 + assert "10001" == resUnLoss.json()["code"], "小于六位的密码进行解挂失败测试不通过"
  380 + assert "密码输入有误" == resUnLoss.json()["message"], "小于六位的密码进行解挂失败测试不通过"
  381 +
  382 + # 大于六位的密码进行解挂
  383 + resUnLoss = cardLostAndUnLost.unLostCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  384 + cardNo=str(self.startCardNo), accountId=accountId,
  385 + customerId=customerId,
  386 + loginPwd="123111123")
  387 + print("resUnLoss", resUnLoss.json())
  388 + assert "10001" == resUnLoss.json()["code"], "大于六位的密码进行解挂失败测试不通过"
  389 + assert "密码输入有误" == resUnLoss.json()["message"], "大于六位的密码进行解挂失败测试不通过"
  390 + """解挂时未进行密码长度验证"""
  391 +
  392 + resUnLoss = cardLostAndUnLost.unLostCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  393 + cardNo=str(self.startCardNo), accountId=accountId,
  394 + customerId=customerId,
  395 + loginPwd=self.loginPwd)
  396 + """测试完成"""
  397 +
testCase/cardSystem/test_openMasterCard.py 0 → 100644
  1 +#coding=utf-8
  2 +
  3 +# @Time : 2021/5/26 10:16
  4 +# @Author : Ljq
  5 +# @File : test_openMasterCard.py
  6 +# @Software: PyCharm
  7 +
  8 +
  9 +"""
  10 + 主卡开卡测试
  11 +"""
  12 +
  13 +import unittest
  14 +import requests
  15 +import time
  16 +import json
  17 +import math
  18 +import commons.api.cardStorageIn as cSI
  19 +import commons.api.returnCard as reC
  20 +import commons.api.cardStorageOut as cSO
  21 +import commons.api.openCard as oMC
  22 +import commons.api.cardStock as cS
  23 +from commons.scripts.createIdNum import cIN
  24 +from commons.api.doLogin import doLogin
  25 +from commons.readConf import readConfig
  26 +
  27 +class tset_openMasterCard(unittest.TestCase):
  28 + def setUp(self) -> None:
  29 + pass
  30 +
  31 + def tearDown(self) -> None:
  32 + pass
  33 +
  34 + @classmethod
  35 + def setUpClass(cls) -> None:
  36 + # 配置信息获取
  37 + readC = readConfig()
  38 + cls.cardHost = readC.returnOptionsItems("host", "cardHost")
  39 + cls.gatewayHost = readC.returnOptionsItems("host", "gatewayHost")
  40 + cls.cCNum = readC.returnOptionsItems("testInfo","cCNum")
  41 + cls.cCNumB = readC.returnOptionsItems("testInfo", "cCNumB")
  42 + cls.cardNum = readC.returnOptionsItems("testInfo", "cardNum")
  43 + cls.cardNumRe = readC.returnOptionsItems("testInfo", "cardNumRe")
  44 + cls.loginPwd = readC.returnOptionsItems("testInfo", "loginPwd")
  45 + # 登录信息获取
  46 + cls.webHeaders, cls.clientHeaders, cls.userInfo = doLogin().loginUser()
  47 + cls.applyUserName = cls.userInfo["data"]["user"]["realName"]
  48 + cls.applyUserId = cls.userInfo["data"]["user"]["id"]
  49 + cls.applyUserCode = cls.userInfo["data"]["user"]["userName"]
  50 + cls.firmId = cls.userInfo["data"]["user"]["firmId"]
  51 +
  52 + @classmethod
  53 + def tearDownClass(cls) -> None:
  54 + pass
  55 +
  56 + def test_getCustomerInfo(self):
  57 + """
  58 + 客户查询测试
  59 + :return:
  60 + """
  61 + # 正确的获取客户信息
  62 + res = oMC.getCustomerInfo(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cCNum=self.cCNum)
  63 + print(res.json())
  64 + assert "200" == res.json()["code"],"使用已存在的客户信息查询失败"
  65 + # 获取客户身份类型
  66 + res = oMC.getSubTypeName(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,customerId=res.json()["data"]["id"])
  67 + assert "200" == res.json()["code"],"查询客户身份类型失败"
  68 + assert "" != res.json()["data"], "身份类型不应该为空"
  69 +
  70 + # 使用不存在的证件号进行查询
  71 + res = oMC.getCustomerInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cCNum=cIN())
  72 + assert "20002" == res.json()["code"], "使用不存在的客户信息查询时查询结果不一致"
  73 +
  74 + def test_checkNewCardNo(self):
  75 + """
  76 + 卡状态校验
  77 + :return:
  78 + """
  79 + # 正向测试卡面校验功能---> #获取客户信息
  80 + print(self.clientHeaders)
  81 + resCusInfo = oMC.getCustomerInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cCNum=self.cCNum)
  82 + print(resCusInfo.json())
  83 + assert "200" == resCusInfo.json()["code"], "使用已存在的客户信息查询失败"
  84 + # 校验
  85 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=self.cardNum,customerId=resCusInfo.json()["data"]["id"],customerType=resCusInfo.json()["data"]["customerType"])
  86 + print("res.json()", res.json())
  87 + assert "200" == res.json()["code"], "使用已存在未开卡的卡片进行校验校验失败"
  88 +
  89 + # 使用未入库的卡片进行校验
  90 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=999999999999,
  91 + customerId=resCusInfo.json()["data"]["id"],
  92 + customerType=resCusInfo.json()["data"]["customerType"])
  93 + assert "10000" == res.json()["code"], "使用已存在未开卡的卡片进行校验校验失败"
  94 + assert "该卡未入库!" == res.json()["message"], "message信息与预期信息不匹配"
  95 +
  96 + # 未出库的卡片进行校验
  97 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  98 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=1)
  99 + if self.firmId == 9:
  100 + startCardNo, endCardNo = 999999999998, 999999999998
  101 + elif self.firmId == 8:
  102 + startCardNo, endCardNo = 999999999997, 999999999997
  103 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  104 + endCardNo=endCardNo, cardFace=cardFace)
  105 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo,
  106 + customerId=resCusInfo.json()["data"]["id"],
  107 + customerType=resCusInfo.json()["data"]["customerType"])
  108 + print(res.json())
  109 + assert "20000" == res.json()["code"], "未出库的卡片进行校验校验失败"
  110 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "未出库卡片校验,message信息与预期信息不匹配"
  111 +
  112 + # 对已开卡的卡片进行校验
  113 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=self.cardNumRe,
  114 + customerId=resCusInfo.json()["data"]["id"],
  115 + customerType=resCusInfo.json()["data"]["customerType"])
  116 + print(res.json())
  117 + assert "20000" == res.json()["code"], "未出库的卡片进行校验校验失败"
  118 + assert "该卡状态为[在用],不能开卡!" == res.json()["message"], "未出库卡片校验,message信息与预期信息不匹配"
  119 +
  120 + def test_getOpenCardFee(self):
  121 + """收费项获取"""
  122 + # 获取开卡手续费
  123 + res = oMC.getOpenCardFee(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders)
  124 + print(res.json())
  125 + assert "200" == res.json()["code"],"开卡手续费获取失败"
  126 + assert "" != res.json()["data"],"开卡手续费获取失败"
  127 +
  128 + def test_openMasterCard(self):
  129 + """
  130 + 正向开卡流程
  131 + :return:
  132 + """
  133 + # 卡片出库
  134 + faceNum = 1
  135 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  136 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  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,
  140 + endCardNo=endCardNo, cardFace=cardFace)
  141 + # 出库
  142 + cardNos = str(startCardNo) + "," + str(endCardNo)
  143 + amount = len([i for i in range(startCardNo, endCardNo + 1)])
  144 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  145 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  146 + applyUserCode=self.applyUserCode, amount=amount)
  147 + assert outCardRes.json()["code"] == "200", "出库失败"
  148 +
  149 +
  150 + # 获取手续费
  151 + costFee = oMC.getOpenCardFee(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders).json()["data"]
  152 + print(costFee)
  153 + # 获取客户信息
  154 + resCusInfo = oMC.getCustomerInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  155 + cCNum=self.cCNum).json()["data"]
  156 + print(resCusInfo)
  157 + # 客户信息准备
  158 + customerName = resCusInfo["name"]
  159 + customerType = resCusInfo["customerType"]
  160 + customerId = resCusInfo["id"]
  161 + customerOrganizationType=resCusInfo["organizationType"]
  162 + customerCredentialType = resCusInfo["certificateType"]
  163 + customerContactsPhone = resCusInfo["customerContactsPhone"]
  164 + customerCertificateNumber = resCusInfo["certificateNumber"]
  165 + customerCode = resCusInfo["code"]
  166 + name = self.applyUserName
  167 + holdName = resCusInfo["name"]
  168 + holdContactsPhone = resCusInfo["customerContactsPhone"]
  169 +
  170 + # 卡片状态校验
  171 + resCheck = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo,
  172 + customerId=customerId,
  173 + customerType=customerType)
  174 + print(resCheck.json())
  175 + assert "200" == resCheck.json()["code"],"卡片校验失败"
  176 +
  177 + # 开卡
  178 + print("开始开卡")
  179 + resOpenCard = oMC.openMasterCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo,
  180 + costFee=costFee, customerName=customerName, customerType=customerType,
  181 + customerId=customerId, loginPwd=self.loginPwd,
  182 + customerOrganizationType=customerOrganizationType,
  183 + customerCredentialType=customerCredentialType,
  184 + customerContactsPhone=customerContactsPhone,
  185 + customerCertificateNumber=customerCertificateNumber, customerCode=customerCode,
  186 + name=name, holdName=holdName, holdContactsPhone=holdContactsPhone,cardType=10)
  187 +
  188 + print("resOpenCard.json()",resOpenCard.json())
  189 +
  190 + assert "200" == resOpenCard.json()["code"],"开卡失败"
  191 + assert None != resOpenCard.json()["data"], "开卡失败"
  192 +
  193 + # 获取卡信息
  194 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  195 +
  196 + def test_dupOpenCard(self):
  197 + """
  198 + 不能重复开卡
  199 + :return:
  200 + """
  201 + # 卡片出库
  202 + faceNum = 1
  203 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  204 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  205 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  206 + endCardNo = startCardNo+1
  207 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  208 + endCardNo=endCardNo, cardFace=cardFace)
  209 + # 出库
  210 + cardNos = str(startCardNo) + "," + str(endCardNo)
  211 + amount = len([i for i in range(startCardNo, endCardNo + 1)])
  212 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  213 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  214 + applyUserCode=self.applyUserCode, amount=amount)
  215 + assert outCardRes.json()["code"] == "200", "出库失败"
  216 +
  217 + # 获取手续费
  218 + costFee = oMC.getOpenCardFee(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders).json()["data"]
  219 + print(costFee)
  220 + # 获取客户信息
  221 + resCusInfo = oMC.getCustomerInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  222 + cCNum=self.cCNum).json()["data"]
  223 + print(resCusInfo)
  224 + # 客户信息准备
  225 + customerName = resCusInfo["name"]
  226 + customerType = resCusInfo["customerType"]
  227 + customerId = resCusInfo["id"]
  228 + customerOrganizationType = resCusInfo["organizationType"]
  229 + customerCredentialType = resCusInfo["certificateType"]
  230 + customerContactsPhone = resCusInfo["customerContactsPhone"]
  231 + customerCertificateNumber = resCusInfo["certificateNumber"]
  232 + customerCode = resCusInfo["code"]
  233 + name = self.applyUserName
  234 + holdName = resCusInfo["name"]
  235 + holdContactsPhone = resCusInfo["customerContactsPhone"]
  236 +
  237 + # 卡片状态校验
  238 + resCheck = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  239 + cardNo=startCardNo,
  240 + customerId=customerId,
  241 + customerType=customerType)
  242 + print(resCheck.json())
  243 + assert "200" == resCheck.json()["code"], "卡片校验失败"
  244 +
  245 + # 开卡
  246 + print("开始开卡")
  247 + resOpenCard = oMC.openMasterCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  248 + cardNo=startCardNo,
  249 + costFee=costFee, customerName=customerName, customerType=customerType,
  250 + customerId=customerId, loginPwd=self.loginPwd,
  251 + customerOrganizationType=customerOrganizationType,
  252 + customerCredentialType=customerCredentialType,
  253 + customerContactsPhone=customerContactsPhone,
  254 + customerCertificateNumber=customerCertificateNumber, customerCode=customerCode,
  255 + name=name, holdName=holdName, holdContactsPhone=holdContactsPhone, cardType=10)
  256 + print("resOpenCard.json()", resOpenCard.json())
  257 + assert "200" == resOpenCard.json()["code"], "开卡失败"
  258 + assert None != resOpenCard.json()["data"], "开卡失败"
  259 +
  260 + resOpenCard = oMC.openMasterCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  261 + cardNo=startCardNo,
  262 + costFee=costFee, customerName=customerName, customerType=customerType,
  263 + customerId=customerId, loginPwd=self.loginPwd,
  264 + customerOrganizationType=customerOrganizationType,
  265 + customerCredentialType=customerCredentialType,
  266 + customerContactsPhone=customerContactsPhone,
  267 + customerCertificateNumber=customerCertificateNumber, customerCode=customerCode,
  268 + name=name, holdName=holdName, holdContactsPhone=holdContactsPhone, cardType=10)
  269 + print("resOpenCard.json()", resOpenCard.json())
  270 + assert "20000" == resOpenCard.json()["code"], "重复开卡失败测试不通过"
  271 + assert "该卡状态为[在用],不能开卡!" == resOpenCard.json()["message"], "重复开卡失败测试不通过"
  272 +
  273 + # 获取卡信息
  274 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  275 +
  276 + def test_oneCardOneCus(self):
  277 + """
  278 + 一张卡只能同时开被开卡给一个用户
  279 + :return:
  280 + """
  281 + # 卡片入库
  282 + faceNum = 1
  283 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  284 + endCardNo = startCardNo+1
  285 +
  286 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  287 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  288 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  289 + endCardNo=endCardNo, cardFace=cardFace)
  290 + # 出库
  291 + cardNos = str(startCardNo) + "," + str(endCardNo)
  292 + amount = len([i for i in range(startCardNo, endCardNo + 1)])
  293 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  294 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  295 + applyUserCode=self.applyUserCode, amount=amount)
  296 + assert outCardRes.json()["code"] == "200", "出库失败"
  297 +
  298 + # 开卡给第一个客户
  299 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cCNum=self.cCNum,cardNo=startCardNo,applyUserName=self.applyUserName)
  300 + assert "200" == resFirstOpen.json()["code"],"第一次开卡,开卡失败"
  301 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  302 +
  303 + # 开卡给第二个客户
  304 + resSecondOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cCNum=self.cCNumB,cardNo=startCardNo,applyUserName=self.applyUserName)
  305 + print("resSecondOpen.json() - - ->",resSecondOpen.json())
  306 + assert "20000" == resSecondOpen.json()["code"], "一张卡不能开卡给多用户测试不通过"
  307 + assert "该卡状态为[在用],不能开卡!" in resSecondOpen.text, "一张卡不能开卡给多用户测试不通过"
  308 +
  309 + # 退卡
  310 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  311 +
  312 + def test_openCardState(self):
  313 + """
  314 + 不同异常状态的卡片在入库时的开卡情况
  315 + :return:
  316 + """
  317 + # 卡片入库
  318 + faceNum = 1
  319 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  320 + endCardNo = startCardNo+1
  321 +
  322 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  323 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  324 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  325 + endCardNo=endCardNo, cardFace=cardFace)
  326 +
  327 + # 已作废的卡片出库失败
  328 + resVoid = cS.cardVoid(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNo=startCardNo)
  329 + print(resVoid.json())
  330 + assert resVoid.json()["code"] == "200", "新出库卡片作废测试失败"
  331 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  332 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  333 + print(resFirstOpen.json())
  334 + assert "20000" == resFirstOpen.json()["code"], "已作废的卡片不能开卡,测试不通过"
  335 + assert "该卡状态为[作废],不能开卡!" == resFirstOpen.json()["message"], "已作废的卡片不能开卡,提示信息错误"
  336 +
  337 + # 未出库的卡片出库失败
  338 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  339 + cCNum=self.cCNum, cardNo=endCardNo, applyUserName=self.applyUserName)
  340 + print(resFirstOpen.json())
  341 + assert "20000" == resFirstOpen.json()["code"], "未激活的卡片不能开卡,测试不通过"
  342 + assert "该卡状态为[未激活],不能开卡!" == resFirstOpen.json()["message"], "未激活的卡片不能开卡,提示信息错误"
  343 +
testCase/cardSystem/test_openSlaveCard.py 0 → 100644
  1 +#coding=utf-8
  2 +
  3 +# @Time : 2021/5/26 10:19
  4 +# @Author : Ljq
  5 +# @File : test_openSlaveCard.py
  6 +# @Software: PyCharm
  7 +
  8 +
  9 +"""
  10 + 副卡开卡测试
  11 +"""
  12 +
  13 +import unittest
  14 +import requests
  15 +import time
  16 +import json
  17 +import math
  18 +import commons.api.cardStorageIn as cSI
  19 +import commons.api.returnCard as reC
  20 +import commons.api.cardStorageOut as cSO
  21 +import commons.api.openCard as oMC
  22 +import commons.api.cardLostAndUnLost as cLAUL
  23 +import commons.api.cardStock as cS
  24 +from commons.readConf import readConfig
  25 +from commons.api.doLogin import doLogin
  26 +
  27 +class tset_openMasterCard(unittest.TestCase):
  28 + def setUp(self) -> None:
  29 + pass
  30 +
  31 + def tearDown(self) -> None:
  32 + pass
  33 +
  34 + @classmethod
  35 + def setUpClass(cls) -> None:
  36 + # 配置信息获取
  37 + readC = readConfig()
  38 + cls.cardHost = readC.returnOptionsItems("host", "cardHost")
  39 + cls.gatewayHost = readC.returnOptionsItems("host", "gatewayHost")
  40 + cls.cCNum = readC.returnOptionsItems("testInfo","cCNum")
  41 + cls.cCNumB = readC.returnOptionsItems("testInfo", "cCNumB")
  42 + cls.cardNum = readC.returnOptionsItems("testInfo", "cardNum")
  43 + cls.cardNumRe = readC.returnOptionsItems("testInfo", "cardNumRe")
  44 + cls.loginPwd = readC.returnOptionsItems("testInfo", "loginPwd")
  45 + # 登录信息获取
  46 + cls.webHeaders, cls.clientHeaders, cls.userInfo = doLogin().loginUser()
  47 + cls.applyUserName = cls.userInfo["data"]["user"]["realName"]
  48 + cls.applyUserId = cls.userInfo["data"]["user"]["id"]
  49 + cls.applyUserCode = cls.userInfo["data"]["user"]["userName"]
  50 + cls.firmId = cls.userInfo["data"]["user"]["firmId"]
  51 +
  52 + @classmethod
  53 + def tearDownClass(cls) -> None:
  54 + pass
  55 +
  56 + def test_getAccountInfo(self):
  57 + """
  58 + 获取卡片信息测试
  59 + :return:
  60 + """
  61 + # 使用未入库的卡片进行获取
  62 + resGet = oMC.getAccountInfo(gatewayHost=self.gatewayHost,clientHeaders =self.clientHeaders,cardNo=999999999999)
  63 + print(resGet.json())
  64 + assert "10001" == resGet.json()["code"],"未入库卡片信息获取测试不通过"
  65 + assert "卡账户不存在" == resGet.json()["message"],"未入库卡片信息获取测试不通过"
  66 +
  67 + # 使用入库未出库的卡片进行信息获取
  68 + # 卡片入库
  69 + faceNum = 1
  70 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  71 + endCardNo = startCardNo + 2
  72 +
  73 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  74 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  75 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  76 + endCardNo=endCardNo, cardFace=cardFace)
  77 + resGet = oMC.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  78 + print(resGet.json())
  79 + assert "10001" == resGet.json()["code"], "未出库卡片信息获取测试不通过"
  80 + assert "卡账户不存在" == resGet.json()["message"], "未出库卡片信息获取测试不通过"
  81 +
  82 + # 使用出库未开卡的卡片进行信息获取
  83 + cardNos = str(startCardNo) + "," + str(endCardNo)
  84 + amount = len([i for i in range(startCardNo, endCardNo + 1)])
  85 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  86 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  87 + applyUserCode=self.applyUserCode, amount=amount)
  88 + assert outCardRes.json()["code"] == "200", "出库失败"
  89 + resGet = oMC.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  90 + print(resGet.json())
  91 + assert "10001" == resGet.json()["code"], "未出库卡片信息获取测试不通过"
  92 + assert "卡账户不存在" == resGet.json()["message"], "未出库卡片信息获取测试不通过"
  93 +
  94 + # 使用已开卡的卡片可以正确的获取到客户信息
  95 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  96 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  97 + assert "200" == resFirstOpen.json()["code"], "开卡失败"
  98 + assert "data" in resFirstOpen.json(), "开卡失败"
  99 + resGet = oMC.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  100 + # print("resGet.json()",resGet.json())
  101 + assert "200" == resGet.json()["code"], "未出库卡片信息获取测试不通过"
  102 + assert "data" in resGet.json(), "未出库卡片信息获取测试不通过"
  103 +
  104 + # 使用已挂失的卡片信息进行卡片信息获取
  105 + accountId,customerId = resGet.json()["data"]["accountId"],resGet.json()["data"]["customerId"]
  106 + resLossCard = cLAUL.lossCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=str(startCardNo),
  107 + accountId=accountId, customerId=customerId, loginPwd=self.loginPwd)
  108 + # print("resLossCard.json()",resLossCard.json())
  109 + assert "200" == resLossCard.json()["code"],"已挂失的卡片获取卡片信息测试不通过"
  110 + resGet = oMC.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  111 + # print("resGet.json()", resGet.json())
  112 + assert "2000" == resGet.json()["code"], "未出库卡片信息获取测试不通过"
  113 + assert "该卡为挂失状态,不能进行此操作" == resGet.json()["message"], "未出库卡片信息获取测试不通过"
  114 + # 解挂
  115 + resUnLoss = cLAUL.unLostCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=str(startCardNo),
  116 + accountId=accountId, customerId=customerId, loginPwd=self.loginPwd)
  117 + # print("resUnLoss.json()",resUnLoss.json())
  118 +
  119 + # 账号冻结状态
  120 +
  121 + # 卡片锁定状态
  122 +
  123 + # 使用已退还的卡片进行卡片信息获取
  124 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  125 + resGet = oMC.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  126 + # print("resGet.json()", resGet.json())
  127 + assert "2000" == resGet.json()["code"], "未出库卡片信息获取测试不通过"
  128 + assert "该卡为退还状态,不能进行此操作" == resGet.json()["message"], "未出库卡片信息获取测试不通过"
  129 +
  130 + def test_checkSlaveCardNo(self):
  131 + """测试副卡校验功能开卡"""
  132 + # 使用未入库的副卡进行校验
  133 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=999999999999,cardType=20)
  134 + print(res.json())
  135 + assert "10000" == res.json()["code"], "使用已存在未开卡的卡片进行校验校验失败"
  136 + assert "该卡未入库!" == res.json()["message"], "message信息与预期信息不匹配"
  137 +
  138 + # 使用未出库的卡片进行校验
  139 + startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  140 + endSlaveCardNo = startSlaveCardNo + 1
  141 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
  142 + endCardNo=endSlaveCardNo, cardType=20)
  143 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo,
  144 + cardType=20)
  145 + print(res.json())
  146 + assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
  147 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  148 +
  149 + # 使用已出库的卡片进行校验
  150 + SlaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
  151 + amount = len([i for i in range(startSlaveCardNo, endSlaveCardNo + 1)])
  152 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=SlaveCardNos,
  153 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  154 + applyUserCode=self.applyUserCode, amount=amount)
  155 + assert outCardRes.json()["code"] == "200", "出库失败"
  156 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo,
  157 + cardType=20)
  158 + print(res.json())
  159 + assert "200" == res.json()["code"], "使用已出库的卡片进行校验校验失败"
  160 + assert "OK" == res.json()["message"], "message信息与预期信息不匹配"
  161 +
  162 + # 使用已作废的卡片进行校验
  163 + resCardVoid = cS.cardVoid(cardHost=self.cardHost,webHeaders=self.webHeaders,cardNo=endSlaveCardNo)
  164 + assert "200"==resCardVoid.json()["code"],"卡片作废失败"
  165 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  166 + cardNo=endSlaveCardNo,
  167 + cardType=20)
  168 + assert "20000" == res.json()["code"], "使用已作废的卡片进行校验校验失败"
  169 + assert "该卡状态为[作废],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  170 +
  171 +
  172 + # 使用已开卡的卡片进行校验
  173 + time.sleep(2)
  174 + faceNum = 1
  175 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  176 + endCardNo = startCardNo+1
  177 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  178 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  179 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  180 + endCardNo=endCardNo, cardFace=cardFace)
  181 + print("resSavaCard.json() ->",resSavaCard.json())
  182 + # 出库
  183 + cardNos = str(startCardNo) + "," + str(endCardNo)
  184 + print(cardNos)
  185 + amount = len([i for i in range(startCardNo, endCardNo)])
  186 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  187 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  188 + applyUserCode=self.applyUserCode, amount=amount)
  189 + assert outCardRes.json()["code"] == "200", "出库失败"
  190 + # 主卡开卡
  191 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  192 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  193 + print("resFirstOpen",resFirstOpen.json())
  194 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  195 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  196 + # 副卡开卡
  197 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  198 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  199 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  200 + parentLoginPwd=self.loginPwd)
  201 + print("resOpenSlaveCard ---> ",resOpenSlaveCard.json())
  202 + resCheckNewCardNo= oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo,
  203 + cardType=20)
  204 + print(resCheckNewCardNo.json())
  205 + assert "20000" == resCheckNewCardNo.json()["code"], "使用已开卡的卡片进行校验校验失败"
  206 + assert "该卡状态为[在用],不能开卡!" == resCheckNewCardNo.json()["message"], "message信息与预期信息不匹配"
  207 + # 副卡退卡
  208 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
  209 +
  210 +
  211 + # 使用已退卡的卡片进行校验
  212 + resCheckNewCardNo = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  213 + cardNo=startSlaveCardNo,
  214 + cardType=20)
  215 + print("203 resCheckNewCardNo ",resCheckNewCardNo.json())
  216 + assert "200" == resCheckNewCardNo.json()["code"], "使用已开卡的卡片进行校验校验失败"
  217 + assert "OK" == resCheckNewCardNo.json()["message"], "message信息与预期信息不匹配"
  218 + # 主卡退卡
  219 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  220 +
  221 +
  222 + def test_openSlaveCard(self):
  223 + """
  224 + 副卡开卡测试
  225 + :return:
  226 + """
  227 + # 主卡入库-出库-开卡
  228 + faceNum = 1
  229 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  230 + endCardNo = startCardNo + 1
  231 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  232 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  233 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  234 + endCardNo=endCardNo, cardFace=cardFace)
  235 + print("resSavaCard.json() ->", resSavaCard.json())
  236 + # 出库
  237 + cardNos = str(startCardNo) + "," + str(endCardNo)
  238 + print(cardNos)
  239 + amount = len([i for i in range(startCardNo, endCardNo)])
  240 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  241 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  242 + applyUserCode=self.applyUserCode, amount=amount)
  243 + assert outCardRes.json()["code"] == "200", "出库失败"
  244 + # 主卡开卡
  245 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  246 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  247 + print("resFirstOpen", resFirstOpen.json())
  248 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  249 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  250 +
  251 + # 副卡入库-出库-开卡
  252 + startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  253 + endSlaveCardNo = startSlaveCardNo + 1
  254 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
  255 + endCardNo=endSlaveCardNo, cardType=20)
  256 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  257 + cardNo=startSlaveCardNo,
  258 + cardType=20)
  259 + print(res.json())
  260 + assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
  261 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  262 + slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
  263 + amount = len([i for i in range(startSlaveCardNo, endSlaveCardNo + 1)])
  264 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
  265 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  266 + applyUserCode=self.applyUserCode, amount=amount)
  267 + assert outCardRes.json()["code"] == "200", "出库失败"
  268 + # 开卡
  269 + costFee = oMC.getOpenCardFee(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders).json()["data"]
  270 + print(costFee)
  271 + resGet = oMC.getAccountInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo).json()["data"]
  272 + print("resGet ---> ", resGet)
  273 + customerName = resGet["customerName"]
  274 + customerId = resGet["customerId"]
  275 + customerCredentialType = resGet["customerCertificateType"]
  276 + customerContactsPhone = resGet["customerContactsPhone"]
  277 + loginPwd = self.loginPwd
  278 + cardNo = startSlaveCardNo
  279 + customerCertificateNumber = resGet["customerCertificateNumber"]
  280 + cardType = 20
  281 + customerCode = resGet["customerCode"]
  282 + name = self.applyUserName
  283 + parentAccountId = resGet["accountId"]
  284 + parentLoginPwd = self.loginPwd
  285 + holdName = customerName
  286 + holdContactsPhone = customerContactsPhone
  287 + resOpenSlaveCard = oMC.openSlaveCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  288 + customerName=customerName,
  289 + customerId=customerId, customerContactsPhone=customerContactsPhone,
  290 + loginPwd=loginPwd, cardNo=cardNo,
  291 + customerCertificateNumber=customerCertificateNumber, cardType=cardType,
  292 + costFee=costFee, customerCode=customerCode,
  293 + name=name, parentAccountId=parentAccountId, parentLoginPwd=parentLoginPwd,
  294 + holdName=holdName,
  295 + holdContactsPhone=holdContactsPhone,
  296 + customerCredentialType=customerCredentialType
  297 + )
  298 +
  299 + # # 办理副卡方法封装
  300 + # resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  301 + # cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  302 + # loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  303 + # parentLoginPwd=self.loginPwd)
  304 +
  305 + print("resOpenSlaveCard.json()", resOpenSlaveCard.json())
  306 + assert "200" == resOpenSlaveCard.json()["code"],"开卡测试失败"
  307 + assert "success" == resOpenSlaveCard.json()["message"], "开卡测试失败"
  308 + # 副卡退卡
  309 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
  310 + # 主卡退卡
  311 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  312 +
  313 + def test_openSlaveCardState(self):
  314 + """
  315 + 异常的副卡办理状态
  316 + :return:
  317 + """
  318 + # 主卡入库-出库-开卡
  319 + faceNum = 1
  320 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  321 + endCardNo = startCardNo + 1
  322 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  323 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  324 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  325 + endCardNo=endCardNo, cardFace=cardFace)
  326 + print("resSavaCard.json() ->", resSavaCard.json())
  327 + # 出库
  328 + cardNos = str(startCardNo) + "," + str(endCardNo)
  329 + print(cardNos)
  330 + amount = len([i for i in range(startCardNo, endCardNo)])
  331 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  332 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  333 + applyUserCode=self.applyUserCode, amount=amount)
  334 + assert outCardRes.json()["code"] == "200", "出库失败"
  335 + # 主卡开卡
  336 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  337 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  338 + print("resFirstOpen", resFirstOpen.json())
  339 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  340 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  341 +
  342 + # 副卡入库-出库-开卡
  343 + startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  344 + endSlaveCardNo = startSlaveCardNo + 1
  345 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
  346 + endCardNo=endSlaveCardNo, cardType=20)
  347 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  348 + cardNo=startSlaveCardNo,
  349 + cardType=20)
  350 + assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
  351 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  352 + slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
  353 + amount = len([i for i in range(startSlaveCardNo, endSlaveCardNo + 1)])
  354 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
  355 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  356 + applyUserCode=self.applyUserCode, amount=amount)
  357 + assert outCardRes.json()["code"] == "200", "出库失败"
  358 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  359 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  360 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  361 + parentLoginPwd=self.loginPwd)
  362 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  363 + # 以上为测试准备
  364 +
  365 + # 卡片不能重复开卡
  366 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  367 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  368 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  369 + parentLoginPwd=self.loginPwd)
  370 + print("resOpenSlaveCard ",resOpenSlaveCard.json())
  371 + assert "20000" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  372 + assert "该卡状态为[在用],不能开卡!" == resOpenSlaveCard.json()["message"], "开卡测试失败"
  373 +
  374 + # 副卡退还后可以重新开卡
  375 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
  376 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  377 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  378 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  379 + parentLoginPwd=self.loginPwd)
  380 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  381 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
  382 +
  383 + # 主卡密码错误时开卡失败
  384 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  385 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  386 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  387 + parentLoginPwd="909090")
  388 + assert "10001" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  389 + assert "密码输入有误" == resOpenSlaveCard.json()["message"], "开卡测试失败"
  390 +
  391 + # 副卡新密码格式不正确-接口暂未校验
  392 +
  393 + # # 副卡退卡
  394 + # reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
  395 + # 主卡退卡
  396 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  397 +
  398 +
testCase/cardSystem/test_outCard.py 0 → 100644
  1 +#coding=utf-8
  2 +
  3 +# @Time : 2021/5/24 9:51
  4 +# @Author : Ljq
  5 +# @File : test_outCard.py
  6 +# @Software: PyCharm
  7 +
  8 +
  9 +"""
  10 + 卡片出库测试用例
  11 +"""
  12 +
  13 +import unittest
  14 +import re
  15 +import time
  16 +import json
  17 +import math
  18 +import commons.api.cardStorageIn as cSI
  19 +import commons.api.cardStock as cS
  20 +import commons.api.cardStorageOut as cSO
  21 +from commons.readConf import readConfig
  22 +from commons.api.doLogin import doLogin
  23 +
  24 +
  25 +class test_outCard(unittest.TestCase):
  26 + @classmethod
  27 + def setUpClass(cls):
  28 + # 获取登录信息和可用headers
  29 + rC = readConfig()
  30 + cls.cardHost = rC.returnOptionsItems("host", "cardHost")
  31 + cls.webHeaders,cls.clientHeaders,cls.userInfo = doLogin().loginUser()
  32 + cls.applyUserName = cls.userInfo["data"]["user"]["realName"]
  33 + cls.applyUserId = cls.userInfo["data"]["user"]["id"]
  34 + cls.applyUserCode = cls.userInfo["data"]["user"]["userName"]
  35 +
  36 + @classmethod
  37 + def tearDownClass(cls):
  38 + pass
  39 +
  40 + def setUp(self):
  41 + time.sleep(2)
  42 + # pass
  43 +
  44 + def tearDown(self):
  45 + pass
  46 +
  47 + def test_openPage(self):
  48 + # 直接打开出库列表
  49 + listRes = cSO.getOutPage(cardHost=self.cardHost,webHeaders=self.webHeaders)
  50 + print(listRes.json())
  51 + assert "200" == listRes.json()["code"],"出库列表查询失败"
  52 +
  53 + def test_outCard_positive(self):
  54 + # 先添加入库卡片
  55 + faceNum = 3
  56 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  57 + endCardNo = startCardNo + 1
  58 + cardFace = cSI.returnFaceValue(resCardFace=cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders),faceNum=faceNum)
  59 + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)
  60 +
  61 + # 出库 ---> 卡片类别获取
  62 + cardTypeRes = cSO.getCardType(cardHost=self.cardHost,webHeaders=self.webHeaders)
  63 + # 获取用户信息
  64 + userInfo = cSO.getUserInfo(cardHost=self.cardHost, webHeaders=self.webHeaders, name=self.applyUserCode,keyword=self.applyUserCode)
  65 + assert userInfo.json()["data"][0]["id"] == self.applyUserId, "获取到的用户信息与实际用户信息不匹配"
  66 + # 出库 ---> 卡面信息获取
  67 + cardFaceB = cSI.returnFaceValue(resCardFace=cSO.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders),faceNum=faceNum)
  68 + # 出库 ---> 卡片入库卡面与当前卡面对比
  69 + for cardNo in range(startCardNo,endCardNo+1):
  70 + cardState = cSO.checkCardForOut(cardHost=self.cardHost, webHeaders=self.webHeaders,cardFace=cardFaceB,cardNo=cardNo)
  71 + assert cardState.json()["code"] == "200","卡片面校验不通过"
  72 + assert cardFace == cardFaceB,"卡面信息断言失败"
  73 + # 出库 ---> 卡片出库
  74 + cardNos = str(startCardNo) + "," + str(endCardNo)
  75 + amount = len([i for i in range(startCardNo,endCardNo+1)])
  76 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost,webHeaders=self.webHeaders,cardNos=cardNos,applyUserName=self.applyUserName,applyUserId=self.applyUserId,applyUserCode=self.applyUserCode,amount=amount)
  77 + assert outCardRes.json()["code"] == "200","出库失败"
  78 +
  79 + # 出库信息断言
  80 + outCardDetail = cSO.getOutCardDetail(cardHost=self.cardHost, webHeaders=self.webHeaders)
  81 + assert sorted(outCardDetail) == sorted([str(i) for i in range(startCardNo,endCardNo+1)]), "返回的出库信息与实际出库信息不一致"
  82 +
  83 + def test_searchUser(self):
  84 + # 先添加入库卡片
  85 + faceNum = 3
  86 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  87 + endCardNo = startCardNo + 1
  88 + cardFace = cSI.returnFaceValue(resCardFace=cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders),
  89 + faceNum=faceNum)
  90 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  91 + endCardNo=endCardNo, cardFace=cardFace)
  92 +
  93 + # 出库 ---> 卡片类别获取
  94 + cardTypeRes = cSO.getCardType(cardHost=self.cardHost, webHeaders=self.webHeaders)
  95 + # 获取用户信息
  96 + userInfo = cSO.getUserInfo(cardHost=self.cardHost, webHeaders=self.webHeaders, name=self.applyUserCode,
  97 + keyword=self.applyUserCode)
  98 + assert userInfo.json()["data"][0]["id"] == self.applyUserId, "获取到的用户信息与实际用户信息不匹配"
  99 + # 出库 ---> 卡面信息获取
  100 + cardFaceB = cSI.returnFaceValue(resCardFace=cSO.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders),
  101 + faceNum=faceNum)
  102 + # 出库 ---> 卡片入库卡面与当前卡面对比
  103 + for cardNo in range(startCardNo, endCardNo + 1):
  104 + cardState = cSO.checkCardForOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardFace=cardFaceB,
  105 + cardNo=cardNo)
  106 + assert cardState.json()["code"] == "200", "卡片面校验不通过"
  107 + assert cardFace == cardFaceB, "卡面信息断言失败"
  108 + # 出库 ---> 卡片出库
  109 + cardNos = str(startCardNo) + "," + str(endCardNo)
  110 + amount = len([i for i in range(startCardNo, endCardNo + 1)])
  111 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  112 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  113 + applyUserCode=self.applyUserCode, amount=amount)
  114 + assert outCardRes.json()["code"] == "200", "出库失败"
  115 +
  116 + # 根据领取人获取最新的出库记录
  117 + listRes = cSO.getOutPage(cardHost=self.cardHost, webHeaders=self.webHeaders,applyUserName=self.applyUserName,
  118 + applyUserId=self.applyUserId)
  119 + assert self.applyUserName == list(set([i["applyUserName"] for i in listRes.json()["rows"]]))[0],"领取人查询成功"
  120 +
  121 + def test_searchCard(self):
  122 + # 先添加入库卡片
  123 + faceNum = 3
  124 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  125 + endCardNo = startCardNo + 1
  126 + cardFace = cSI.returnFaceValue(resCardFace=cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders),
  127 + faceNum=faceNum)
  128 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  129 + endCardNo=endCardNo, cardFace=cardFace)
  130 +
  131 + # 出库 ---> 卡片类别获取
  132 + cardTypeRes = cSO.getCardType(cardHost=self.cardHost, webHeaders=self.webHeaders)
  133 + # 获取用户信息
  134 + userInfo = cSO.getUserInfo(cardHost=self.cardHost, webHeaders=self.webHeaders, name=self.applyUserCode,
  135 + keyword=self.applyUserCode)
  136 + assert userInfo.json()["data"][0]["id"] == self.applyUserId, "获取到的用户信息与实际用户信息不匹配"
  137 + # 出库 ---> 卡面信息获取
  138 + cardFaceB = cSI.returnFaceValue(resCardFace=cSO.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders),
  139 + faceNum=faceNum)
  140 + # 出库 ---> 卡片入库卡面与当前卡面对比
  141 + for cardNo in range(startCardNo, endCardNo + 1):
  142 + cardState = cSO.checkCardForOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardFace=cardFaceB,
  143 + cardNo=cardNo)
  144 + assert cardState.json()["code"] == "200", "卡片面校验不通过"
  145 + assert cardFace == cardFaceB, "卡面信息断言失败"
  146 + # 出库 ---> 卡片出库
  147 + cardNos = str(startCardNo) + "," + str(endCardNo)
  148 + amount = len([i for i in range(startCardNo, endCardNo + 1)])
  149 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  150 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  151 + applyUserCode=self.applyUserCode, amount=amount)
  152 + assert outCardRes.json()["code"] == "200", "出库失败"
  153 +
  154 + # 根据领取人获取最新的出库记录
  155 + listRes = cSO.getOutPage(cardHost=self.cardHost, webHeaders=self.webHeaders,cardNo=startCardNo)
  156 + assert 1 == len([i for i in listRes.json()["rows"]]),"查询结果不唯一,查询失败"
  157 + firstId = listRes.json()["rows"][0]["id"]
  158 + resDetail = cSO.getOutListDetail(cardHost=self.cardHost, webHeaders=self.webHeaders, id=firstId)
  159 + outCardDetail = re.findall("<ul><li>(.*?)</li></ul>", resDetail.text)
  160 + assert str(startCardNo) in outCardDetail,"查询失败"
  161 +
  162 + def test_searchDate(self):
  163 + # 先添加入库卡片
  164 + faceNum = 3
  165 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  166 + endCardNo = startCardNo + 1
  167 + cardFace = cSI.returnFaceValue(resCardFace=cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders),
  168 + faceNum=faceNum)
  169 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  170 + endCardNo=endCardNo, cardFace=cardFace)
  171 +
  172 + # 出库 ---> 卡片类别获取
  173 + cardTypeRes = cSO.getCardType(cardHost=self.cardHost, webHeaders=self.webHeaders)
  174 + # 获取用户信息
  175 + userInfo = cSO.getUserInfo(cardHost=self.cardHost, webHeaders=self.webHeaders, name=self.applyUserCode,
  176 + keyword=self.applyUserCode)
  177 + assert userInfo.json()["data"][0]["id"] == self.applyUserId, "获取到的用户信息与实际用户信息不匹配"
  178 + # 出库 ---> 卡面信息获取
  179 + cardFaceB = cSI.returnFaceValue(resCardFace=cSO.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders),
  180 + faceNum=faceNum)
  181 + # 出库 ---> 卡片入库卡面与当前卡面对比
  182 + for cardNo in range(startCardNo, endCardNo + 1):
  183 + cardState = cSO.checkCardForOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardFace=cardFaceB,
  184 + cardNo=cardNo)
  185 + assert cardState.json()["code"] == "200", "卡片面校验不通过"
  186 + assert cardFace == cardFaceB, "卡面信息断言失败"
  187 + # 出库 ---> 卡片出库
  188 + cardNos = str(startCardNo) + "," + str(endCardNo)
  189 + amount = len([i for i in range(startCardNo, endCardNo + 1)])
  190 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  191 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  192 + applyUserCode=self.applyUserCode, amount=amount)
  193 + assert outCardRes.json()["code"] == "200", "出库失败"
  194 +
  195 + # 根据领取人获取最新的出库记录
  196 + startDate = str(time.strftime("%Y-%m-%d 00:00:00", time.localtime()))
  197 + endDate = str(time.strftime("%Y-%m-%d 23:59:59", time.localtime()))
  198 + listRes = cSO.getOutPage(cardHost=self.cardHost, webHeaders=self.webHeaders,startDate=startDate,endDate=endDate)
  199 + pageNum = math.ceil(listRes.json()["total"]/10)
  200 + listRes = cSO.getOutPage(cardHost=self.cardHost, webHeaders=self.webHeaders, startDate=startDate,
  201 + endDate=endDate,page=pageNum)
  202 + dateList = [i["applyTime"] for i in listRes.json()["rows"]]
  203 + assert [] == [i for i in dateList if i < startDate or i > endDate], "查询结果错误,查询出非当天的入库信息"
  204 +
  205 + def test_searchAllOption(self):
  206 + # 先添加入库卡片
  207 + faceNum = 3
  208 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  209 + endCardNo = startCardNo + 1
  210 + cardFace = cSI.returnFaceValue(resCardFace=cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders),
  211 + faceNum=faceNum)
  212 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  213 + endCardNo=endCardNo, cardFace=cardFace)
  214 +
  215 + # 出库 ---> 卡片类别获取
  216 + cardTypeRes = cSO.getCardType(cardHost=self.cardHost, webHeaders=self.webHeaders)
  217 + # 获取用户信息
  218 + userInfo = cSO.getUserInfo(cardHost=self.cardHost, webHeaders=self.webHeaders, name=self.applyUserCode,
  219 + keyword=self.applyUserCode)
  220 + assert userInfo.json()["data"][0]["id"] == self.applyUserId, "获取到的用户信息与实际用户信息不匹配"
  221 + # 出库 ---> 卡面信息获取
  222 + cardFaceB = cSI.returnFaceValue(resCardFace=cSO.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders),
  223 + faceNum=faceNum)
  224 + # 出库 ---> 卡片入库卡面与当前卡面对比
  225 + for cardNo in range(startCardNo, endCardNo + 1):
  226 + cardState = cSO.checkCardForOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardFace=cardFaceB,
  227 + cardNo=cardNo)
  228 + assert cardState.json()["code"] == "200", "卡片面校验不通过"
  229 + assert cardFace == cardFaceB, "卡面信息断言失败"
  230 + # 出库 ---> 卡片出库
  231 + cardNos = str(startCardNo) + "," + str(endCardNo)
  232 + amount = len([i for i in range(startCardNo, endCardNo + 1)])
  233 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  234 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  235 + applyUserCode=self.applyUserCode, amount=amount)
  236 + assert outCardRes.json()["code"] == "200", "出库失败"
  237 +
  238 + # 根据领取人获取最新的出库记录
  239 + startDate = str(time.strftime("%Y-%m-%d 00:00:00", time.localtime()))
  240 + endDate = str(time.strftime("%Y-%m-%d 23:59:59", time.localtime()))
  241 + # 根据领取人获取最新的出库记录
  242 + listRes = cSO.getOutPage(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNo=startCardNo,startDate=startDate,endDate=endDate,applyUserName=self.applyUserName,
  243 + applyUserId=self.applyUserId)
  244 + assert 1 == len([i for i in listRes.json()["rows"]]), "查询结果不唯一,查询失败"
  245 + firstId = listRes.json()["rows"][0]["id"]
  246 + resDetail = cSO.getOutListDetail(cardHost=self.cardHost, webHeaders=self.webHeaders, id=firstId)
  247 + outCardDetail = re.findall("<ul><li>(.*?)</li></ul>", resDetail.text)
  248 + assert str(startCardNo) in outCardDetail, "查询失败"
  249 +
  250 + def test_checkCardState(self):
  251 + # 先添加入库卡片
  252 + faceNum = 3
  253 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  254 + endCardNo = startCardNo + 1
  255 + cardFace = cSI.returnFaceValue(resCardFace=cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders),
  256 + faceNum=faceNum)
  257 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  258 + endCardNo=endCardNo, cardFace=cardFace)
  259 +
  260 + # 出库 ---> 卡片类别获取
  261 + cardTypeRes = cSO.getCardType(cardHost=self.cardHost, webHeaders=self.webHeaders)
  262 + # 获取用户信息
  263 + userInfo = cSO.getUserInfo(cardHost=self.cardHost, webHeaders=self.webHeaders, name=self.applyUserCode,
  264 + keyword=self.applyUserCode)
  265 + assert userInfo.json()["data"][0]["id"] == self.applyUserId, "获取到的用户信息与实际用户信息不匹配"
  266 + # 出库 ---> 卡面信息获取
  267 + cardFaceB = cSI.returnFaceValue(resCardFace=cSO.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders),
  268 + faceNum=faceNum)
  269 + # 出库 ---> 卡片入库卡面与当前卡面对比
  270 + for cardNo in range(startCardNo, endCardNo + 1):
  271 + cardState = cSO.checkCardForOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardFace=cardFaceB,
  272 + cardNo=cardNo)
  273 + assert cardState.json()["code"] == "200", "卡片面校验不通过"
  274 + assert cardFace == cardFaceB, "卡面信息断言失败"
  275 + # 出库 ---> 卡片出库
  276 + cardNos = str(startCardNo) + "," + str(endCardNo)
  277 + amount = len([i for i in range(startCardNo, endCardNo + 1)])
  278 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  279 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  280 + applyUserCode=self.applyUserCode, amount=amount)
  281 + assert outCardRes.json()["code"] == "200", "出库失败"
  282 +
  283 + # 已出库的卡在出库页面进行状态校验
  284 + for cardNo in range(startCardNo, endCardNo + 1):
  285 + cardState = cSO.checkCardForOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardFace=cardFaceB,
  286 + cardNo=cardNo)
  287 + assert cardState.json()["message"] == "该卡状态为[激活],不能进行此操作!", "提示信息错误"
  288 + assert cardState.json()["code"] == "5000", "出库失败"
  289 +
  290 + # 未出库的卡校验
  291 + cardState = cSO.checkCardForOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardFace=cardFaceB,
  292 + cardNo=startCardNo+2)
  293 + assert cardState.json()["message"] == "该卡未入库!", "提示信息错误"
  294 + assert cardState.json()["code"] == "10000", "未出库的卡片状态校验失败"
  295 +
  296 + # 已开卡的状态校验,暂缺
  297 +
  298 +
testCase/cardSystem/test_pwdModify.py 0 → 100644
  1 +#coding=utf-8
  2 +
  3 +# @Time : 2021/6/11 14:35
  4 +# @Author : Ljq
  5 +# @File : test_pwdModify.py
  6 +# @Software: PyCharm
  7 +
  8 +
  9 +"""
  10 +
  11 +"""
  12 +
  13 +import unittest
  14 +import random
  15 +import time
  16 +import json
  17 +import math
  18 +import commons.api.cardStorageIn as cSI
  19 +import commons.api.returnCard as reC
  20 +import commons.api.cardStorageOut as cSO
  21 +import commons.api.openCard as oMC
  22 +import commons.api.operatePwd as operatePwd
  23 +from commons.readConf import readConfig
  24 +from commons.api.doLogin import doLogin
  25 +
  26 +class test_pwdModify(unittest.TestCase):
  27 + def setUp(self) -> None:
  28 + pass
  29 +
  30 + def tearDown(self) -> None:
  31 + pass
  32 +
  33 + @classmethod
  34 + def setUpClass(cls) -> None:
  35 + # 配置信息获取
  36 + readC = readConfig()
  37 + cls.cardHost = readC.returnOptionsItems("host", "cardHost")
  38 + cls.gatewayHost = readC.returnOptionsItems("host", "gatewayHost")
  39 + cls.cCNum = readC.returnOptionsItems("testInfo","cCNum")
  40 + cls.cCNumB = readC.returnOptionsItems("testInfo", "cCNumB")
  41 + cls.cardNum = readC.returnOptionsItems("testInfo", "cardNum")
  42 + cls.cardNumRe = readC.returnOptionsItems("testInfo", "cardNumRe")
  43 + cls.loginPwd = readC.returnOptionsItems("testInfo", "loginPwd")
  44 + # 登录信息获取
  45 + cls.webHeaders, cls.clientHeaders, cls.userInfo = doLogin().loginUser()
  46 + cls.applyUserName = cls.userInfo["data"]["user"]["realName"]
  47 + cls.applyUserId = cls.userInfo["data"]["user"]["id"]
  48 + cls.applyUserCode = cls.userInfo["data"]["user"]["userName"]
  49 + cls.firmId = cls.userInfo["data"]["user"]["firmId"]
  50 +
  51 + @classmethod
  52 + def tearDownClass(cls) -> None:
  53 + pass
  54 +
  55 + def producePwd(self):
  56 + pwd = "".join(random.sample("0123456789", 6))
  57 + return pwd
  58 +
  59 + def test_pwdModify(self):
  60 + """修改密码正向流程测试"""
  61 + # 主卡入库-出库-开卡
  62 + faceNum = 1
  63 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  64 + endCardNo = startCardNo + 2
  65 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  66 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  67 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  68 + endCardNo=endCardNo, cardFace=cardFace)
  69 + print("resSavaCard.json() ->", resSavaCard.json())
  70 + cardNos = str(startCardNo) + "," + str(endCardNo)
  71 + print(cardNos)
  72 + amount = 2
  73 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  74 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  75 + applyUserCode=self.applyUserCode, amount=amount)
  76 + assert outCardRes.json()["code"] == "200", "出库失败"
  77 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  78 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  79 + print("resFirstOpen", resFirstOpen.json())
  80 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  81 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  82 + # 副卡入库-出库-开卡
  83 + startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  84 + endSlaveCardNo = startSlaveCardNo + 2
  85 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
  86 + endCardNo=endSlaveCardNo, cardType=20)
  87 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  88 + cardNo=startSlaveCardNo,
  89 + cardType=20)
  90 + assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
  91 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  92 + slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
  93 + amount = 2
  94 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
  95 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  96 + applyUserCode=self.applyUserCode, amount=amount)
  97 + assert outCardRes.json()["code"] == "200", "出库失败"
  98 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  99 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  100 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  101 + parentLoginPwd=self.loginPwd)
  102 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  103 + # 开卡结束-获取卡片客户信息
  104 + resSimpleInfo = operatePwd.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  105 + cardNo=startCardNo)
  106 + customerId,accountId = resSimpleInfo.json()["data"]["accountInfo"]["customerId"],resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
  107 + resSimpleInfo = operatePwd.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  108 + cardNo=startSlaveCardNo)
  109 + customerIdSlaveCard, accountIdSlaveCard = resSimpleInfo.json()["data"]["accountInfo"]["customerId"], \
  110 + resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
  111 + # 以上为测试数据准备
  112 +
  113 + """开始测试"""
  114 +
  115 + # 主卡正常修改密码
  116 + newPwd = self.producePwd()
  117 + print("newPwd",newPwd)
  118 + resRLP = operatePwd.modifyLoginPwd(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,oldLoginPwd=self.loginPwd,
  119 + loginPwd=newPwd,secondLoginPwd=newPwd,cardNo=startCardNo,accountId=accountId,customerId=customerId)
  120 + # print(resRLP.json())
  121 + assert "200" == resRLP.json()["code"],"主卡正常修改密码测试不通过"
  122 + assert "OK" == resRLP.json()["message"], "主卡正常修改密码测试不通过"
  123 +
  124 + # 副卡正常修改密码
  125 + newPwdSlave = self.producePwd()
  126 + # print("newPwdSlave",newPwdSlave)
  127 + resRLP = operatePwd.modifyLoginPwd(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,oldLoginPwd=self.loginPwd,loginPwd=newPwdSlave,
  128 + secondLoginPwd=newPwdSlave,cardNo=startSlaveCardNo,accountId=accountIdSlaveCard,customerId=customerIdSlaveCard)
  129 + print(resRLP.json())
  130 + assert "200" == resRLP.json()["code"],"副卡正常修改密码测试不通过"
  131 + assert "OK" == resRLP.json()["message"], "副卡正常修改密码测试不通过"
  132 +
  133 + """测试完成"""
  134 +
  135 + # 副卡退卡
  136 + resSlave = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo,loginPwd=newPwdSlave)
  137 + assert "200" == resSlave.json()["code"],"副卡使用新密码退卡成功,密码修改成功"
  138 + assert "OK" == resSlave.json()["message"], "副卡使用新密码退卡成功,密码修改成功"
  139 + # 主卡退卡
  140 + res = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo,loginPwd=newPwd)
  141 + assert "200" == res.json()["code"],"主卡使用新密码退卡成功,密码修改成功"
  142 + assert "OK" == res.json()["message"], "主卡使用新密码退卡成功,密码修改成功"
  143 +
  144 + def test_pwdModifyError(self):
  145 + """修改密码异常流程"""
  146 + # 主卡入库-出库-开卡
  147 + faceNum = 1
  148 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  149 + endCardNo = startCardNo + 2
  150 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  151 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  152 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  153 + endCardNo=endCardNo, cardFace=cardFace)
  154 + print("resSavaCard.json() ->", resSavaCard.json())
  155 + cardNos = str(startCardNo) + "," + str(endCardNo)
  156 + print(cardNos)
  157 + amount = 2
  158 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  159 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  160 + applyUserCode=self.applyUserCode, amount=amount)
  161 + assert outCardRes.json()["code"] == "200", "出库失败"
  162 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  163 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  164 + print("resFirstOpen", resFirstOpen.json())
  165 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  166 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  167 + # 副卡入库-出库-开卡
  168 + startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  169 + endSlaveCardNo = startSlaveCardNo + 2
  170 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
  171 + endCardNo=endSlaveCardNo, cardType=20)
  172 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  173 + cardNo=startSlaveCardNo,
  174 + cardType=20)
  175 + assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
  176 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  177 + slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
  178 + amount = 2
  179 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
  180 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  181 + applyUserCode=self.applyUserCode, amount=amount)
  182 + assert outCardRes.json()["code"] == "200", "出库失败"
  183 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  184 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  185 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  186 + parentLoginPwd=self.loginPwd)
  187 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  188 + # 开卡结束-获取卡片客户信息
  189 + resSimpleInfo = operatePwd.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  190 + cardNo=startCardNo)
  191 + customerId,accountId = resSimpleInfo.json()["data"]["accountInfo"]["customerId"],resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
  192 + resSimpleInfo = operatePwd.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  193 + cardNo=startSlaveCardNo)
  194 + customerIdSlaveCard, accountIdSlaveCard = resSimpleInfo.json()["data"]["accountInfo"]["customerId"], \
  195 + resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
  196 + # 以上为测试数据准备
  197 +
  198 + """开始测试"""
  199 +
  200 + # 副卡原密码错误修改失败
  201 + newPwdSlave = self.producePwd()
  202 + resRLP = operatePwd.modifyLoginPwd(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, oldLoginPwd="909090",
  203 + loginPwd=newPwdSlave,
  204 + secondLoginPwd=newPwdSlave, cardNo=startSlaveCardNo, accountId=accountIdSlaveCard,
  205 + customerId=customerIdSlaveCard)
  206 + assert "10001" == resRLP.json()["code"], "副卡原密码错误修改失败测试不通过"
  207 + assert "密码输入有误" == resRLP.json()["message"], "副卡原密码错误修改失败测试不通过"
  208 + resSlave = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  209 + cardNo=startSlaveCardNo, loginPwd=newPwdSlave)
  210 + assert "10001" == resSlave.json()["code"], "修改密码失败后不能使用新密码退卡,测试不通过"
  211 + # 主卡原密码错误修改失败
  212 + newPwd = self.producePwd()
  213 + resRLP = operatePwd.modifyLoginPwd(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,oldLoginPwd="909090",
  214 + loginPwd=newPwd,secondLoginPwd=newPwd,cardNo=startCardNo,accountId=accountId,customerId=customerId)
  215 + assert "10001" == resRLP.json()["code"],"主卡原密码错误修改失败测试不通过"
  216 + assert "密码输入有误" == resRLP.json()["message"], "主卡原密码错误修改失败测试不通过"
  217 + res = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo,
  218 + loginPwd=newPwd)
  219 + assert "10001" == res.json()["code"], "修改密码失败后不能使用新密码退卡,测试不通过"
  220 +
  221 + # 两次输入的新密码不一致时修改密码失败
  222 + newPwdSlave = self.producePwd()
  223 + resRLP = operatePwd.modifyLoginPwd(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, oldLoginPwd=self.loginPwd,
  224 + loginPwd="909090",secondLoginPwd=newPwdSlave, cardNo=startSlaveCardNo,
  225 + accountId=accountIdSlaveCard, customerId=customerIdSlaveCard)
  226 + print(resRLP.json())
  227 + assert "2000" == resRLP.json()["code"], "副卡两次输入的新密码不一致时修改密码失败测试不通过"
  228 + assert "两次输入密码不匹配" == resRLP.json()["message"], "副卡两次输入的新密码不一致时修改密码失败测试不通过"
  229 + resSlave = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  230 + cardNo=startSlaveCardNo, loginPwd=newPwdSlave)
  231 + assert "10001" == resSlave.json()["code"], "修改密码失败后不能使用新密码退卡,测试不通过"
  232 + # 主卡原密码错误修改失败
  233 + newPwd = self.producePwd()
  234 + resRLP = operatePwd.modifyLoginPwd(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, oldLoginPwd=self.loginPwd,
  235 + loginPwd="909090", secondLoginPwd=newPwd, cardNo=startCardNo, accountId=accountId,
  236 + customerId=customerId)
  237 + print(resRLP.json())
  238 + assert "2000" == resRLP.json()["code"], "主卡两次输入的新密码不一致时修改密码失败测试不通过"
  239 + assert "两次输入密码不匹配" == resRLP.json()["message"], "主卡两次输入的新密码不一致时修改密码失败测试不通过"
  240 + res = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo,
  241 + loginPwd=newPwd)
  242 + assert "10001" == res.json()["code"], "修改密码失败后不能使用新密码退卡,测试不通过"
  243 +
  244 + # 第一个密码输入长度不满足六位时修改失败
  245 + newPwdSlave = self.producePwd()
  246 + resRLP = operatePwd.modifyLoginPwd(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, oldLoginPwd=self.loginPwd,
  247 + loginPwd="90909",secondLoginPwd=newPwdSlave, cardNo=startSlaveCardNo,
  248 + accountId=accountIdSlaveCard, customerId=customerIdSlaveCard)
  249 + print(resRLP.json())
  250 + assert "1000" == resRLP.json()["code"], "副卡第一个密码输入长度不满足六位时修改失败测试不通过"
  251 + assert "密码必须6位" == resRLP.json()["message"], "副卡第一个密码输入长度不满足六位时修改失败测试不通过"
  252 + resSlave = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  253 + cardNo=startSlaveCardNo, loginPwd=newPwdSlave)
  254 + assert "10001" == resSlave.json()["code"], "修改密码失败后不能使用新密码退卡,测试不通过"
  255 + # 主卡原密码错误修改失败
  256 + newPwd = self.producePwd()
  257 + resRLP = operatePwd.modifyLoginPwd(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, oldLoginPwd=self.loginPwd,
  258 + loginPwd="90909", secondLoginPwd=newPwd, cardNo=startCardNo, accountId=accountId,
  259 + customerId=customerId)
  260 + print(resRLP.json())
  261 + assert "1000" == resRLP.json()["code"], "主卡第一个密码输入长度不满足六位时修改失败测试不通过"
  262 + assert "密码必须6位" == resRLP.json()["message"], "主卡第一个密码输入长度不满足六位时修改失败测试不通过"
  263 + res = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo,
  264 + loginPwd=newPwd)
  265 + assert "10001" == res.json()["code"], "修改密码失败后不能使用新密码退卡,测试不通过"
  266 +
  267 + # 第二个密码输入长度不满足六位时修改失败
  268 + newPwdSlave = self.producePwd()
  269 + resRLP = operatePwd.modifyLoginPwd(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  270 + oldLoginPwd=self.loginPwd,
  271 + loginPwd=newPwdSlave, secondLoginPwd="90909", cardNo=startSlaveCardNo,
  272 + accountId=accountIdSlaveCard, customerId=customerIdSlaveCard)
  273 + print(resRLP.json())
  274 + assert "1000" == resRLP.json()["code"], "副卡第二个密码输入长度不满足六位时修改失败测试不通过"
  275 + assert "确认密码密码必须6位" == resRLP.json()["message"], "副卡第二个密码输入长度不满足六位时修改失败测试不通过"
  276 + resSlave = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  277 + cardNo=startSlaveCardNo, loginPwd=newPwdSlave)
  278 + assert "10001" == resSlave.json()["code"], "修改密码失败后不能使用新密码退卡,测试不通过"
  279 + # 主卡原密码错误修改失败
  280 + newPwd = self.producePwd()
  281 + resRLP = operatePwd.modifyLoginPwd(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  282 + oldLoginPwd=self.loginPwd,
  283 + loginPwd=newPwd, secondLoginPwd="90909", cardNo=startCardNo, accountId=accountId,
  284 + customerId=customerId)
  285 + print(resRLP.json())
  286 + assert "1000" == resRLP.json()["code"], "主卡第二个密码输入长度不满足六位时修改失败测试不通过"
  287 + assert "确认密码密码必须6位" == resRLP.json()["message"], "主卡第二个密码输入长度不满足六位时修改失败测试不通过"
  288 + res = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo,
  289 + loginPwd=newPwd)
  290 + assert "10001" == res.json()["code"], "修改密码失败后不能使用新密码退卡,测试不通过"
  291 +
  292 + """测试完成"""
  293 +
  294 + # # 副卡退卡
  295 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
  296 + reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
0 \ No newline at end of file 297 \ No newline at end of file
testCase/cardSystem/test_pwdReset.py 0 → 100644
  1 +#coding=utf-8
  2 +
  3 +# @Time : 2021/6/11 14:36
  4 +# @Author : Ljq
  5 +# @File : test_pwdReset.py
  6 +# @Software: PyCharm
  7 +
  8 +
  9 +"""
  10 + 重置密码功能接口测试
  11 +"""
  12 +
  13 +
  14 +import unittest
  15 +import random
  16 +import time
  17 +import json
  18 +import math
  19 +import commons.api.cardStorageIn as cSI
  20 +import commons.api.returnCard as reC
  21 +import commons.api.cardStorageOut as cSO
  22 +import commons.api.openCard as oMC
  23 +import commons.api.operatePwd as oP
  24 +from commons.readConf import readConfig
  25 +from commons.api.doLogin import doLogin
  26 +
  27 +class test_pwdModify(unittest.TestCase):
  28 + def setUp(self) -> None:
  29 + pass
  30 +
  31 + def tearDown(self) -> None:
  32 + pass
  33 +
  34 + @classmethod
  35 + def setUpClass(cls) -> None:
  36 + # 配置信息获取
  37 + readC = readConfig()
  38 + cls.cardHost = readC.returnOptionsItems("host", "cardHost")
  39 + cls.gatewayHost = readC.returnOptionsItems("host", "gatewayHost")
  40 + cls.cCNum = readC.returnOptionsItems("testInfo","cCNum")
  41 + cls.cCNumB = readC.returnOptionsItems("testInfo", "cCNumB")
  42 + cls.cardNum = readC.returnOptionsItems("testInfo", "cardNum")
  43 + cls.cardNumRe = readC.returnOptionsItems("testInfo", "cardNumRe")
  44 + cls.loginPwd = readC.returnOptionsItems("testInfo", "loginPwd")
  45 + # 登录信息获取
  46 + cls.webHeaders, cls.clientHeaders, cls.userInfo = doLogin().loginUser()
  47 + cls.applyUserName = cls.userInfo["data"]["user"]["realName"]
  48 + cls.applyUserId = cls.userInfo["data"]["user"]["id"]
  49 + cls.applyUserCode = cls.userInfo["data"]["user"]["userName"]
  50 + cls.firmId = cls.userInfo["data"]["user"]["firmId"]
  51 +
  52 + @classmethod
  53 + def tearDownClass(cls) -> None:
  54 + pass
  55 +
  56 + def producePwd(self):
  57 + pwd = "".join(random.sample("0123456789", 6))
  58 + return pwd
  59 +
  60 + def test_pwdModify(self):
  61 + """修改密码正向流程测试"""
  62 + # 主卡入库-出库-开卡
  63 + faceNum = 1
  64 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  65 + endCardNo = startCardNo + 2
  66 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  67 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  68 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  69 + endCardNo=endCardNo, cardFace=cardFace)
  70 + print("resSavaCard.json() ->", resSavaCard.json())
  71 + cardNos = str(startCardNo) + "," + str(endCardNo)
  72 + print(cardNos)
  73 + amount = 2
  74 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  75 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  76 + applyUserCode=self.applyUserCode, amount=amount)
  77 + assert outCardRes.json()["code"] == "200", "出库失败"
  78 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  79 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  80 + print("resFirstOpen", resFirstOpen.json())
  81 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  82 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  83 + # 副卡入库-出库-开卡
  84 + startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  85 + endSlaveCardNo = startSlaveCardNo + 2
  86 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
  87 + endCardNo=endSlaveCardNo, cardType=20)
  88 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  89 + cardNo=startSlaveCardNo,
  90 + cardType=20)
  91 + assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
  92 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  93 + slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
  94 + amount = 2
  95 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
  96 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  97 + applyUserCode=self.applyUserCode, amount=amount)
  98 + assert outCardRes.json()["code"] == "200", "出库失败"
  99 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  100 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  101 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  102 + parentLoginPwd=self.loginPwd)
  103 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  104 + # 开卡结束-获取卡片客户信息
  105 + resSimpleInfo = oP.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  106 + cardNo=startCardNo)
  107 + customerId,accountId = resSimpleInfo.json()["data"]["accountInfo"]["customerId"],resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
  108 + resSimpleInfo = oP.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  109 + cardNo=startSlaveCardNo)
  110 + customerIdSlaveCard, accountIdSlaveCard = resSimpleInfo.json()["data"]["accountInfo"]["customerId"], \
  111 + resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
  112 + # 以上为测试数据准备
  113 +
  114 + """开始测试"""
  115 +
  116 + # 主卡正常重置密码
  117 + newPwd = self.producePwd()
  118 + print("newPwd",newPwd)
  119 + resRLP = oP.resetLoginPwd(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,loginPwd=newPwd,
  120 + secondLoginPwd=newPwd,cardNo=startCardNo,accountId=accountId,customerId=customerId)
  121 + assert "200" == resRLP.json()["code"],"主卡正常重置密码测试不通过"
  122 + assert "OK" == resRLP.json()["message"], "主卡正常重置密码测试不通过"
  123 +
  124 + # 副卡正常重置密码
  125 + newPwdSlave = self.producePwd()
  126 + print("newPwdSlave",newPwdSlave)
  127 + resRLP = oP.resetLoginPwd(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,loginPwd=newPwdSlave,
  128 + secondLoginPwd=newPwdSlave,cardNo=startSlaveCardNo,accountId=accountIdSlaveCard,customerId=customerIdSlaveCard)
  129 + assert "200" == resRLP.json()["code"],"副卡正常重置密码测试不通过"
  130 + assert "OK" == resRLP.json()["message"], "副卡正常重置密码测试不通过"
  131 +
  132 + """测试完成"""
  133 +
  134 + # 副卡退卡
  135 + resSlave = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo,loginPwd=newPwdSlave)
  136 + assert "200" == resSlave.json()["code"],"副卡使用新密码退卡成功,密码重置成功"
  137 + assert "OK" == resSlave.json()["message"], "副卡使用新密码退卡成功,密码重置成功"
  138 + # 主卡退卡
  139 + res = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo,loginPwd=newPwd)
  140 + assert "200" == res.json()["code"],"主卡使用新密码退卡成功,密码重置成功"
  141 + assert "OK" == res.json()["message"], "主卡使用新密码退卡成功,密码重置成功"
  142 +
  143 + def test_pwdModifyError(self):
  144 + """修改密码异常流程测试 部分用例后续添加"""
  145 + # 主卡入库-出库-开卡
  146 + faceNum = 1
  147 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  148 + endCardNo = startCardNo + 2
  149 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  150 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
  151 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
  152 + endCardNo=endCardNo, cardFace=cardFace)
  153 + print("resSavaCard.json() ->", resSavaCard.json())
  154 + cardNos = str(startCardNo) + "," + str(endCardNo)
  155 + print(cardNos)
  156 + amount = 2
  157 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
  158 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  159 + applyUserCode=self.applyUserCode, amount=amount)
  160 + assert outCardRes.json()["code"] == "200", "出库失败"
  161 + resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  162 + cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
  163 + print("resFirstOpen", resFirstOpen.json())
  164 + assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
  165 + assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
  166 + # 副卡入库-出库-开卡
  167 + startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  168 + endSlaveCardNo = startSlaveCardNo + 2
  169 + resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
  170 + endCardNo=endSlaveCardNo, cardType=20)
  171 + res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  172 + cardNo=startSlaveCardNo,
  173 + cardType=20)
  174 + assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
  175 + assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
  176 + slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
  177 + amount = 2
  178 + outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
  179 + applyUserName=self.applyUserName, applyUserId=self.applyUserId,
  180 + applyUserCode=self.applyUserCode, amount=amount)
  181 + assert outCardRes.json()["code"] == "200", "出库失败"
  182 + resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  183 + cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
  184 + loginPwd=self.loginPwd, applyUserName=self.applyUserName,
  185 + parentLoginPwd=self.loginPwd)
  186 + assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
  187 + # 开卡结束-获取卡片客户信息
  188 + resSimpleInfo = oP.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  189 + cardNo=startCardNo)
  190 + customerId,accountId = resSimpleInfo.json()["data"]["accountInfo"]["customerId"],resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
  191 + resSimpleInfo = oP.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  192 + cardNo=startSlaveCardNo)
  193 + customerIdSlaveCard, accountIdSlaveCard = resSimpleInfo.json()["data"]["accountInfo"]["customerId"], \
  194 + resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
  195 + # 以上为测试数据准备
  196 +
  197 + """开始测试"""
  198 +
  199 + # 副卡使用两个不一致的密码进行重置时重置失败
  200 + newPwdSlave = self.producePwd()
  201 + print("newPwdSlave", newPwdSlave)
  202 + resRLP = oP.resetLoginPwd(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, loginPwd="123456",
  203 + secondLoginPwd=newPwdSlave, cardNo=startSlaveCardNo, accountId=accountIdSlaveCard,
  204 + customerId=customerIdSlaveCard)
  205 + print(resRLP.json())
  206 + assert "2000" == resRLP.json()["code"], "副卡正常重置密码测试不通过"
  207 + assert "两次密码输入不一致,请重新输入" == resRLP.json()["message"], "副卡正常重置密码测试不通过"
  208 + resSlave = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
  209 + cardNo=startSlaveCardNo, loginPwd=newPwdSlave)
  210 + assert "10001" == resSlave.json()["code"], "重置密码失败后不能使用新密码退卡,测试不通过"
  211 +
  212 +
  213 + # 主卡使用两个不一致的密码进行重置时重置失败
  214 + newPwd = self.producePwd()
  215 + print("newPwd",newPwd)
  216 + resRLP = oP.resetLoginPwd(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,loginPwd="123456",
  217 + secondLoginPwd=newPwd,cardNo=startCardNo,accountId=accountId,customerId=customerId)
  218 + print(resRLP.json())
  219 + assert "2000" == resRLP.json()["code"],"主卡正常重置密码测试不通过"
  220 + assert "两次密码输入不一致,请重新输入" == resRLP.json()["message"], "主卡正常重置密码测试不通过"
  221 + res = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo,loginPwd=newPwd)
  222 + assert "10001" == res.json()["code"],"重置密码失败后不能使用新密码退卡,测试不通过"
  223 +
  224 + # 挂失的卡片不可以重置密码
  225 +
  226 + # 卡务锁定的卡片不可以重置密码
  227 +
  228 + # 账号冻结的卡片不可以重置密码
  229 +
  230 + # 资金账号锁定的卡片可以重置密码
  231 +
  232 + """测试完成"""
  233 +
  234 + # 副卡退卡
  235 + resSlave = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
  236 + # assert "200" == resSlave.json()["code"],"副卡使用新密码退卡成功,密码重置成功"
  237 + # assert "OK" == resSlave.json()["message"], "副卡使用新密码退卡成功,密码重置成功"
  238 + # 主卡退卡
  239 + res = reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
  240 + # assert "200" == res.json()["code"],"主卡使用新密码退卡成功,密码重置成功"
  241 + # assert "OK" == res.json()["message"], "主卡使用新密码退卡成功,密码重置成功"
  242 +
  243 +
main.py renamed to testCase/main.py
@@ -25,7 +25,7 @@ def Create_Testcase_suite(): @@ -25,7 +25,7 @@ def Create_Testcase_suite():
25 '''创建测试套件''' 25 '''创建测试套件'''
26 testunit = unittest.TestSuite() 26 testunit = unittest.TestSuite()
27 test_Loader = DiscoveringTestLoader() 27 test_Loader = DiscoveringTestLoader()
28 - discover = test_Loader.discover("./testcase/", pattern='test_*.py', top_level_dir=None) 28 + discover = test_Loader.discover("./", pattern='test_*.py', top_level_dir=None)
29 print(discover) 29 print(discover)
30 for test_suite in discover: 30 for test_suite in discover:
31 testunit.addTests(test_suite) 31 testunit.addTests(test_suite)
@@ -37,7 +37,7 @@ def Run_Testcase(testsuit): @@ -37,7 +37,7 @@ def Run_Testcase(testsuit):
37 '''运行测试用例并生成报告''' 37 '''运行测试用例并生成报告'''
38 now = time.strftime("%Y-%m-%d %H_%M_%S", time.localtime()) 38 now = time.strftime("%Y-%m-%d %H_%M_%S", time.localtime())
39 path = os.path.dirname(os.path.abspath(sys.argv[0])) 39 path = os.path.dirname(os.path.abspath(sys.argv[0]))
40 - report_file = path + "/report/" + now + "_result.html" 40 + report_file = os.path.abspath(os.path.join(path, "../"))+ "/report/" + now + "_result.html"
41 # 创建报告文件 41 # 创建报告文件
42 fp = open(report_file, 'wb') 42 fp = open(report_file, 'wb')
43 43