Commit cfc61f518a9656face3209be805c53c154b2dba9

Authored by liujiqiang
1 parent 2bc04883

更新

commons/scripts/delReport.py
@@ -11,20 +11,22 @@ @@ -11,20 +11,22 @@
11 11
12 import os,sys 12 import os,sys
13 13
14 -def delReport(path,delNum=5):  
15 - # print("path",path)  
16 - if os.name == "nt":  
17 - report_route = os.path.abspath(os.path.join(path, "../")) 14 +def path_route(path):
  15 + if "report" not in os.listdir(path):
  16 + return path_route(os.path.abspath(os.path.join(path, "../")))
18 else: 17 else:
19 - report_route = os.path.abspath(os.path.join(path))  
20 - file_list = os.listdir(report_route + "/report/")  
21 - # print("delReport file_lis --- ", file_list) 18 + return path
  19 +
  20 +def delReport(path,delNum=5):
  21 + project_path = path_route(path)
  22 + file_list = os.listdir(project_path + "/report/")
  23 + print("delReport file_lis --- ", file_list)
22 if len(file_list) > delNum: 24 if len(file_list) > delNum:
23 file_list = file_list[:0-delNum] 25 file_list = file_list[:0-delNum]
24 # print("if file_lis --- ",file_list) 26 # print("if file_lis --- ",file_list)
25 for i in file_list: 27 for i in file_list:
26 - if os.path.isfile(report_route + "/report/" + i) and ".log" not in i:  
27 - os.remove(report_route + "/report/" + i) 28 + if os.path.isfile(project_path + "/report/" + i) and ".log" not in i:
  29 + os.remove(project_path + "/report/" + i)
28 print(f"删除报告 {i} 成功") 30 print(f"删除报告 {i} 成功")
29 # 文件已删除 31 # 文件已删除
30 print("多余的报告文件已删除") 32 print("多余的报告文件已删除")
@@ -37,7 +37,7 @@ def Create_Testcase_suite(): @@ -37,7 +37,7 @@ def Create_Testcase_suite():
37 def Run_Testcase(testsuit): 37 def Run_Testcase(testsuit):
38 '''运行测试用例并生成报告''' 38 '''运行测试用例并生成报告'''
39 now = time.strftime("%Y-%m-%d %H_%M_%S", time.localtime()) 39 now = time.strftime("%Y-%m-%d %H_%M_%S", time.localtime())
40 - path = os.path.dirname(os.path.abspath(sys.argv[0])) 40 + path = os.path.dirname(__file__)
41 report_file = os.path.abspath(os.path.join(path))+ "/report/" + now + "_result.html" 41 report_file = os.path.abspath(os.path.join(path))+ "/report/" + now + "_result.html"
42 # 创建报告文件 42 # 创建报告文件
43 fp = open(report_file, 'wb') 43 fp = open(report_file, 'wb')
report/cardSystem/__init__.py 0 → 100644
  1 +# -*- coding: utf-8 -*-
  2 +
  3 +# @Time : 2021/7/16 14:36
  4 +# @Author : Ljq
  5 +# @File : __init__.py.py
  6 +# @Software: PyCharm
  7 +
  8 +"""
  9 +
  10 +"""
report/cardSystem/test_addCard.py 0 → 100644
  1 +# -*- coding: utf-8 -*-
  2 +
  3 +# @Time : 2021/7/16 14:44
  4 +# @Author : Ljq
  5 +# @File : test_addCard.py
  6 +# @Software: PyCharm
  7 +
  8 +"""
  9 +卡片入库测试
  10 +"""
  11 +
  12 +import unittest
  13 +import time
  14 +import math
  15 +import commons.api.cardStorageIn as cSI
  16 +import commons.api.cardStock as cS
  17 +import commons.api.cardStorageOut as cSO
  18 +from commons.scripts.readConf import readConfig
  19 +from commons.api.doLogin import doLogin
  20 +
  21 +
  22 +class test_addCard(unittest.TestCase):
  23 + @classmethod
  24 + def setUpClass(cls):
  25 + # 获取登录信息和可用headers
  26 + rC = readConfig()
  27 + cls.cardHost = rC.returnOptionsItems("host", "cardHost")
  28 + cls.webHeaders,cls.clientHeaders,cls.userInfo = doLogin().loginUser()
  29 + cls.applyUserName = cls.userInfo["data"]["user"]["realName"]
  30 + cls.applyUserId = cls.userInfo["data"]["user"]["id"]
  31 + cls.applyUserCode = cls.userInfo["data"]["user"]["userName"]
  32 + # print("self.webHeaders", cls.webHeaders)
  33 + # print("self.clientHeaders", cls.clientHeaders)
  34 + # print("self.userInfo", cls.userInfo)
  35 +
  36 + def setUp(self) -> None:
  37 + time.sleep(2)
  38 +
  39 + def test_cardType(self):
  40 + """
  41 + 卡类型校验
  42 + :return:
  43 + """
  44 + resCardType = cSI.getCardType(cardHost=self.cardHost, webHeaders=self.webHeaders)
  45 + preRes = [{"text":"-- 全部 --","value":""},{"text":"主卡","value":10},{"text":"副卡","value":20}]
  46 + assert resCardType.json()==preRes,"卡类型信息错误"
  47 +
  48 + def test_cardFaceCheck(self):
  49 + """
  50 + 市场卡面信息校验
  51 + :return:
  52 + """
  53 + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)
  54 + print(resCardFace.json())
  55 + if self.userInfo["data"]["user"]["firmId"] == 8:
  56 + # 预期结果定义
  57 + preRes = [{'text': '-- 请选择 --', 'value': ''}, {'text': '买方卡', 'value': 'buyer'}, {'text': 'VIP买方卡', 'value': 'buyer_vip'}, {'text': '卖方卡', 'value': 'seller'}, {'text': '司机卡', 'value': 'driver'}]
  58 + assert resCardFace.json()==preRes,"当 firmId = 8 时卡面信息错误"
  59 + else:
  60 + preRes = [{"text":"-- 无--","value":""}]
  61 + assert resCardFace.json() == preRes, "当 firmId != 8 时卡面信息错误"
  62 +
  63 + def test_doCardStorageIn(self):
  64 + """
  65 + 卡片入库测试,新添加的卡片能正常的入库
  66 + :return:
  67 + """
  68 + # 获取卡面信息
  69 + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)
  70 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3)
  71 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  72 + endCardNo = startCardNo + 1
  73 + # 执行入库
  74 + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)
  75 + # print(resSavaCard.json())
  76 + assert resSavaCard.json()["message"]=="OK","入库失败"
  77 + resQueryList = cSI.queryList(cardHost=self.cardHost,webHeaders=self.webHeaders)
  78 + # 入库卡片号段校验
  79 + assert resQueryList.json()["rows"][0]["cardNoRange"]==str(startCardNo)+"-"+str(endCardNo),"入库的卡片在入库列表不能被查询到"
  80 + # 入库数量校验
  81 + assert resQueryList.json()["rows"][0]["amount"]==2,"入库数量错误"
  82 + # 入库角色校验
  83 + assert resQueryList.json()["rows"][0]["creator"]==self.userInfo["data"]["user"]["realName"],"入库角色记录正确"
  84 + assert resQueryList.json()["rows"][0]["creatorId"] == self.userInfo["data"]["user"]["id"], "入库角色记录正确"
  85 + # resQueryList.json()["rows"][0]["cardFaceText"]
  86 + if self.userInfo["data"]["user"]["firmId"] == 8:
  87 + assert cardFace==resQueryList.json()["rows"][0]["cardFace"],"记录的卡面信息与实际卡面不一致"
  88 + else:
  89 + assert "cardFaceText" not in resQueryList.text,"记录的卡面信息与实际卡面不一致"
  90 +
  91 + def test_duplicateStorageIn(self):
  92 + """
  93 + 测试卡片不能被重复入库
  94 + :return:
  95 + """
  96 + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)
  97 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3)
  98 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  99 + endCardNo = startCardNo+1
  100 + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)
  101 + assert resSavaCard.json()["message"]=="OK","入库失败"
  102 + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)
  103 + assert resSavaCard.json()["message"]=="入库失败,包含重复卡号%s~%s"%(startCardNo,endCardNo),"卡片不能重复入库验证失败"
  104 +
  105 + def test_openCardStorageIn(self):
  106 + """
  107 + 入库列表查询测试
  108 + :return:
  109 + """
  110 + # 全列表查询
  111 + resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)
  112 + # print(resQueryList.json()["total"])
  113 + assert resQueryList.json()["total"]>200,"页数小于10,查询结果可能存在错误"
  114 +
  115 + # 查询当天入库的入库记录,判断所得的查询记录的日期都是当天的为测试通过
  116 + startDate = str(time.strftime("%Y-%m-%d 00:00:00", time.localtime()))
  117 + endDate = str(time.strftime("%Y-%m-%d 23:59:59", time.localtime()))
  118 + resQueryLista = cSI.queryList(cardHost=self.cardHost,webHeaders=self.webHeaders,startDate=startDate,endDate=endDate)
  119 + dateList=[]
  120 + pageNums = math.ceil(resQueryLista.json()["total"]/10)
  121 + for pageNum in range(pageNums):
  122 + resQueryLista = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders, startDate=startDate,
  123 + endDate=endDate,page=str(pageNum+1))
  124 + dateList = dateList+[i["createTime"] for i in resQueryLista.json()["rows"]]
  125 + assert [] == [i for i in dateList if i<startDate or i>endDate],"查询结果错误,查询出非当天的入库信息"
  126 +
  127 + def test_addMasterCard(self):
  128 + """
  129 + 添加主卡
  130 + :return:
  131 + """
  132 + resCardType = cSI.getCardType(cardHost=self.cardHost,webHeaders=self.webHeaders)
  133 + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)
  134 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3)
  135 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  136 + endCardNo = startCardNo+1
  137 + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)
  138 + resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)
  139 + assert resQueryList.json()["rows"][0]["cardType"]==10,"卡片类型错误"
  140 +
  141 +
  142 + def test_addSlaveCard(self):
  143 + """
  144 + 添加副卡
  145 + :return:
  146 + """
  147 + resCardType = cSI.getCardType(cardHost=self.cardHost,webHeaders=self.webHeaders)
  148 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  149 + endCardNo = startCardNo+1
  150 + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardType=20)
  151 + print(resSavaCard.json())
  152 + resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)
  153 + assert resQueryList.json()["rows"][0]["cardType"] == 20, "卡片类型错误"
  154 + assert resQueryList.json()["rows"][0]["cardTypeText"] == "副卡", "卡片类型错误"
  155 + assert "cardFaceText" not in str(resQueryList.json()["rows"][0]),"副卡不应该存在卡面"
  156 +
  157 +
  158 + def test_delStorageInRecord(self):
  159 + """
  160 + 正常删除卡片记录
  161 + :return:
  162 + """
  163 + # 新增加一条入库记录用于删除
  164 + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)
  165 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3)
  166 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  167 + endCardNo = startCardNo + 1
  168 + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)
  169 + assert resSavaCard.json()["message"]=="OK","入库失败"
  170 + resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)
  171 + ida = resQueryList.json()['rows'][0]['id']
  172 + resDel = cSI.delCard(cardHost=self.cardHost,webHeaders=self.webHeaders,ids=ida)
  173 + assert resDel.json()["message"]=="OK","删除失败,入库记录未被成功删除"
  174 + resQueryListB = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)
  175 + idb = resQueryListB.json()['rows'][0]['id']
  176 + print(ida,"----------------",idb)
  177 + assert ida!=idb,"删除功能异常,记录未被删除"
  178 +
  179 + def test_delStorageInRecordFail_delCard(self):
  180 + """
  181 + 已作废的卡片不能被删除
  182 + :return:
  183 + """
  184 + resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)
  185 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3)
  186 + startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
  187 + endCardNo = startCardNo+1
  188 + resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)
  189 + # 卡片作废
  190 + cS.cardVoid(cardHost=self.cardHost,webHeaders=self.webHeaders,cardNo=startCardNo)
  191 + # 删除入库记录
  192 + resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)
  193 + ida = resQueryList.json()['rows'][0]['id']
  194 + resDel = cSI.delCard(cardHost=self.cardHost, webHeaders=self.webHeaders, ids=ida)
  195 + print(resDel.json())
  196 + assert resDel.json()["message"]=="有部分卡片已出库或作废,删除失败","已作废的卡片不能被删除"
  197 +
  198 + def test_delStorageInRecordFail_cardOut(self):
  199 + """
  200 + 存在出库卡片的入库记录,不能进行删除
  201 + :return:
  202 + """
  203 + resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
  204 + cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=3)
  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 + acc = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=str(startCardNo),applyUserName=self.applyUserName,applyUserCode=self.applyUserCode,applyUserId=self.applyUserId)
  211 + # print(acc.json())
  212 + # 删除入库记录
  213 + resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)
  214 + ida = resQueryList.json()['rows'][0]['id']
  215 + resDel = cSI.delCard(cardHost=self.cardHost, webHeaders=self.webHeaders, ids=ida)
  216 + # print(resDel.json())
  217 + assert resDel.json()["message"] == "有部分卡片已出库或作废,删除失败", "已出库的卡片不能被删除"
  218 +
  219 + @classmethod
  220 + def tearDownClass(cls):
  221 + print("tearDown")
  222 +
  223 + def tearDown(self) -> None:
  224 + pass
  225 +
  226 +if __name__== "__main__":
  227 + unittest.main()
0 \ No newline at end of file 228 \ No newline at end of file
testCase/cardSystem/test_cardStorage.py renamed to report/cardSystem/test_cardStorage.py
testCase/cardSystem/test_changeCard.py renamed to report/cardSystem/test_changeCard.py
testCase/cardSystem/test_lossCard.py renamed to report/cardSystem/test_lossCard.py
testCase/cardSystem/test_openMasterCard.py renamed to report/cardSystem/test_openMasterCard.py
testCase/cardSystem/test_openSlaveCard.py renamed to report/cardSystem/test_openSlaveCard.py
testCase/cardSystem/test_outCard.py renamed to report/cardSystem/test_outCard.py
testCase/cardSystem/test_pwdModify.py renamed to report/cardSystem/test_pwdModify.py
testCase/cardSystem/test_pwdReset.py renamed to report/cardSystem/test_pwdReset.py
report/test.log
  1 +[2021-07-21 10:39:13] [INFO] : 发送邮件
  2 +[2021-07-21 10:39:15] [INFO] : 邮件发送完毕
testCase/cardSystem/test_addCard.py
@@ -45,177 +45,6 @@ class test_addCard(unittest.TestCase): @@ -45,177 +45,6 @@ class test_addCard(unittest.TestCase):
45 preRes = [{"text":"-- 全部 --","value":""},{"text":"主卡","value":10},{"text":"副卡","value":20}] 45 preRes = [{"text":"-- 全部 --","value":""},{"text":"主卡","value":10},{"text":"副卡","value":20}]
46 assert resCardType.json()==preRes,"卡类型信息错误" 46 assert resCardType.json()==preRes,"卡类型信息错误"
47 47
48 - def test_cardFaceCheck(self):  
49 - """  
50 - 市场卡面信息校验  
51 - :return:  
52 - """  
53 - resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)  
54 - print(resCardFace.json())  
55 - if self.userInfo["data"]["user"]["firmId"] == 8:  
56 - # 预期结果定义  
57 - preRes = [{'text': '-- 请选择 --', 'value': ''}, {'text': '买方卡', 'value': 'buyer'}, {'text': 'VIP买方卡', 'value': 'buyer_vip'}, {'text': '卖方卡', 'value': 'seller'}, {'text': '司机卡', 'value': 'driver'}]  
58 - assert resCardFace.json()==preRes,"当 firmId = 8 时卡面信息错误"  
59 - else:  
60 - preRes = [{"text":"-- 无--","value":""}]  
61 - assert resCardFace.json() == preRes, "当 firmId != 8 时卡面信息错误"  
62 -  
63 - def test_doCardStorageIn(self):  
64 - """  
65 - 卡片入库测试,新添加的卡片能正常的入库  
66 - :return:  
67 - """  
68 - # 获取卡面信息  
69 - resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)  
70 - cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3)  
71 - startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))  
72 - endCardNo = startCardNo + 1  
73 - # 执行入库  
74 - resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)  
75 - # print(resSavaCard.json())  
76 - assert resSavaCard.json()["message"]=="OK","入库失败"  
77 - resQueryList = cSI.queryList(cardHost=self.cardHost,webHeaders=self.webHeaders)  
78 - # 入库卡片号段校验  
79 - assert resQueryList.json()["rows"][0]["cardNoRange"]==str(startCardNo)+"-"+str(endCardNo),"入库的卡片在入库列表不能被查询到"  
80 - # 入库数量校验  
81 - assert resQueryList.json()["rows"][0]["amount"]==2,"入库数量错误"  
82 - # 入库角色校验  
83 - assert resQueryList.json()["rows"][0]["creator"]==self.userInfo["data"]["user"]["realName"],"入库角色记录正确"  
84 - assert resQueryList.json()["rows"][0]["creatorId"] == self.userInfo["data"]["user"]["id"], "入库角色记录正确"  
85 - # resQueryList.json()["rows"][0]["cardFaceText"]  
86 - if self.userInfo["data"]["user"]["firmId"] == 8:  
87 - assert cardFace==resQueryList.json()["rows"][0]["cardFace"],"记录的卡面信息与实际卡面不一致"  
88 - else:  
89 - assert "cardFaceText" not in resQueryList.text,"记录的卡面信息与实际卡面不一致"  
90 -  
91 - def test_duplicateStorageIn(self):  
92 - """  
93 - 测试卡片不能被重复入库  
94 - :return:  
95 - """  
96 - resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)  
97 - cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3)  
98 - startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))  
99 - endCardNo = startCardNo+1  
100 - resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)  
101 - assert resSavaCard.json()["message"]=="OK","入库失败"  
102 - resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)  
103 - assert resSavaCard.json()["message"]=="入库失败,包含重复卡号%s~%s"%(startCardNo,endCardNo),"卡片不能重复入库验证失败"  
104 -  
105 - def test_openCardStorageIn(self):  
106 - """  
107 - 入库列表查询测试  
108 - :return:  
109 - """  
110 - # 全列表查询  
111 - resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)  
112 - # print(resQueryList.json()["total"])  
113 - assert resQueryList.json()["total"]>200,"页数小于10,查询结果可能存在错误"  
114 -  
115 - # 查询当天入库的入库记录,判断所得的查询记录的日期都是当天的为测试通过  
116 - startDate = str(time.strftime("%Y-%m-%d 00:00:00", time.localtime()))  
117 - endDate = str(time.strftime("%Y-%m-%d 23:59:59", time.localtime()))  
118 - resQueryLista = cSI.queryList(cardHost=self.cardHost,webHeaders=self.webHeaders,startDate=startDate,endDate=endDate)  
119 - dateList=[]  
120 - pageNums = math.ceil(resQueryLista.json()["total"]/10)  
121 - for pageNum in range(pageNums):  
122 - resQueryLista = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders, startDate=startDate,  
123 - endDate=endDate,page=str(pageNum+1))  
124 - dateList = dateList+[i["createTime"] for i in resQueryLista.json()["rows"]]  
125 - assert [] == [i for i in dateList if i<startDate or i>endDate],"查询结果错误,查询出非当天的入库信息"  
126 -  
127 - def test_addMasterCard(self):  
128 - """  
129 - 添加主卡  
130 - :return:  
131 - """  
132 - resCardType = cSI.getCardType(cardHost=self.cardHost,webHeaders=self.webHeaders)  
133 - resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)  
134 - cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3)  
135 - startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))  
136 - endCardNo = startCardNo+1  
137 - resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)  
138 - resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)  
139 - assert resQueryList.json()["rows"][0]["cardType"]==10,"卡片类型错误"  
140 -  
141 -  
142 - def test_addSlaveCard(self):  
143 - """  
144 - 添加副卡  
145 - :return:  
146 - """  
147 - resCardType = cSI.getCardType(cardHost=self.cardHost,webHeaders=self.webHeaders)  
148 - startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))  
149 - endCardNo = startCardNo+1  
150 - resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardType=20)  
151 - print(resSavaCard.json())  
152 - resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)  
153 - assert resQueryList.json()["rows"][0]["cardType"] == 20, "卡片类型错误"  
154 - assert resQueryList.json()["rows"][0]["cardTypeText"] == "副卡", "卡片类型错误"  
155 - assert "cardFaceText" not in str(resQueryList.json()["rows"][0]),"副卡不应该存在卡面"  
156 -  
157 -  
158 - def test_delStorageInRecord(self):  
159 - """  
160 - 正常删除卡片记录  
161 - :return:  
162 - """  
163 - # 新增加一条入库记录用于删除  
164 - resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)  
165 - cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3)  
166 - startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))  
167 - endCardNo = startCardNo + 1  
168 - resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)  
169 - assert resSavaCard.json()["message"]=="OK","入库失败"  
170 - resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)  
171 - ida = resQueryList.json()['rows'][0]['id']  
172 - resDel = cSI.delCard(cardHost=self.cardHost,webHeaders=self.webHeaders,ids=ida)  
173 - assert resDel.json()["message"]=="OK","删除失败,入库记录未被成功删除"  
174 - resQueryListB = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)  
175 - idb = resQueryListB.json()['rows'][0]['id']  
176 - print(ida,"----------------",idb)  
177 - assert ida!=idb,"删除功能异常,记录未被删除"  
178 -  
179 - def test_delStorageInRecordFail_delCard(self):  
180 - """  
181 - 已作废的卡片不能被删除  
182 - :return:  
183 - """  
184 - resCardFace = cSI.getCardFace(cardHost=self.cardHost,webHeaders=self.webHeaders)  
185 - cardFace = cSI.returnFaceValue(resCardFace=resCardFace,faceNum=3)  
186 - startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))  
187 - endCardNo = startCardNo+1  
188 - resSavaCard = cSI.savaCard(cardHost=self.cardHost,webHeaders=self.webHeaders,startCardNo=startCardNo,endCardNo=endCardNo,cardFace=cardFace)  
189 - # 卡片作废  
190 - cS.cardVoid(cardHost=self.cardHost,webHeaders=self.webHeaders,cardNo=startCardNo)  
191 - # 删除入库记录  
192 - resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)  
193 - ida = resQueryList.json()['rows'][0]['id']  
194 - resDel = cSI.delCard(cardHost=self.cardHost, webHeaders=self.webHeaders, ids=ida)  
195 - print(resDel.json())  
196 - assert resDel.json()["message"]=="有部分卡片已出库或作废,删除失败","已作废的卡片不能被删除"  
197 -  
198 - def test_delStorageInRecordFail_cardOut(self):  
199 - """  
200 - 存在出库卡片的入库记录,不能进行删除  
201 - :return:  
202 - """  
203 - resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)  
204 - cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=3)  
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 - acc = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=str(startCardNo),applyUserName=self.applyUserName,applyUserCode=self.applyUserCode,applyUserId=self.applyUserId)  
211 - # print(acc.json())  
212 - # 删除入库记录  
213 - resQueryList = cSI.queryList(cardHost=self.cardHost, webHeaders=self.webHeaders)  
214 - ida = resQueryList.json()['rows'][0]['id']  
215 - resDel = cSI.delCard(cardHost=self.cardHost, webHeaders=self.webHeaders, ids=ida)  
216 - # print(resDel.json())  
217 - assert resDel.json()["message"] == "有部分卡片已出库或作废,删除失败", "已出库的卡片不能被删除"  
218 -  
219 @classmethod 48 @classmethod
220 def tearDownClass(cls): 49 def tearDownClass(cls):
221 print("tearDown") 50 print("tearDown")
testCase/main.py
@@ -37,7 +37,7 @@ def Create_Testcase_suite(): @@ -37,7 +37,7 @@ def Create_Testcase_suite():
37 def Run_Testcase(testsuit): 37 def Run_Testcase(testsuit):
38 '''运行测试用例并生成报告''' 38 '''运行测试用例并生成报告'''
39 now = time.strftime("%Y-%m-%d %H_%M_%S", time.localtime()) 39 now = time.strftime("%Y-%m-%d %H_%M_%S", time.localtime())
40 - path = os.path.dirname(os.path.abspath(sys.argv[0])) 40 + path = os.path.dirname(os.path.abspath(__file__))
41 report_file = os.path.abspath(os.path.join(path, "../"))+ "/report/" + now + "_result.html" 41 report_file = os.path.abspath(os.path.join(path, "../"))+ "/report/" + now + "_result.html"
42 # 创建报告文件 42 # 创建报告文件
43 fp = open(report_file, 'wb') 43 fp = open(report_file, 'wb')