test_changeCard.py
36.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
#coding=utf-8
# @Time : 2021/6/1 10:02
# @Author : Ljq
# @File : test_changeCard.py
# @Software: PyCharm
"""
"""
import unittest
import requests
import time
import json
import math
import commons.api.cardStorageIn as cSI
import commons.api.returnCard as reC
import commons.api.cardStorageOut as cSO
import commons.api.openCard as oMC
import commons.api.cardStock as cS
import commons.api.changeCard as cC
from commons.readConf import readConfig
from commons.api.doLogin import doLogin
class tset_changeCard(unittest.TestCase):
def setUp(self) -> None:
time.sleep(3)
def tearDown(self) -> None:
pass
@classmethod
def setUpClass(cls) -> None:
# 配置信息获取
readC = readConfig()
cls.cardHost = readC.returnOptionsItems("host", "cardHost")
cls.gatewayHost = readC.returnOptionsItems("host", "gatewayHost")
cls.cCNum = readC.returnOptionsItems("testInfo","cCNum")
cls.cCNumB = readC.returnOptionsItems("testInfo", "cCNumB")
cls.cardNum = readC.returnOptionsItems("testInfo", "cardNum")
cls.cardNumRe = readC.returnOptionsItems("testInfo", "cardNumRe")
cls.loginPwd = readC.returnOptionsItems("testInfo", "loginPwd")
# 登录信息获取
cls.webHeaders, cls.clientHeaders, cls.userInfo = doLogin().loginUser()
cls.applyUserName = cls.userInfo["data"]["user"]["realName"]
cls.applyUserId = cls.userInfo["data"]["user"]["id"]
cls.applyUserCode = cls.userInfo["data"]["user"]["userName"]
cls.firmId = cls.userInfo["data"]["user"]["firmId"]
@classmethod
def tearDownClass(cls) -> None:
pass
def test_getSimpleInfo(self):
"""用户信息获取"""
# 未入库的卡片进行客户信息获取
notInCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
res = cC.getSimpleInfo(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=notInCardNo)
print(res.json())
assert "10001" == res.json()["code"], "未入库的卡片进行信息获取,测试不通过"
assert "卡账户不存在" == res.json()["message"], "未入库的卡片进行信息获取,测试不通过"
# 入库未开卡的卡片进行信息获取
faceNum = 1
startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
endCardNo = startCardNo + 1
resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
endCardNo=endCardNo, cardFace=cardFace)
print("resSavaCard.json() ->", resSavaCard.json())
res = cC.getSimpleInfo(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startCardNo)
print(res.json())
assert "10001" == res.json()["code"], "未出库的卡片进行信息获取,测试不通过"
assert "卡账户不存在" == res.json()["message"], "未出库的卡片进行信息获取,测试不通过"
# 出库未开卡的卡片进行信息获取
cardNos = str(startCardNo) + "," + str(endCardNo)
print(cardNos)
amount = len([i for i in range(startCardNo, endCardNo)])
outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
applyUserName=self.applyUserName, applyUserId=self.applyUserId,
applyUserCode=self.applyUserCode, amount=amount)
assert outCardRes.json()["code"] == "200", "出库失败"
res = cC.getSimpleInfo(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startCardNo)
print(res.json())
assert "10001" == res.json()["code"], "出库未开卡的卡片进行信息获取,测试不通过"
assert "卡账户不存在" == res.json()["message"], "出库未开卡的卡片进行信息获取,测试不通过"
# 正常的主卡获取客户信息
resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
print("resFirstOpen", resFirstOpen.json())
assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
res = cC.getSimpleInfo(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startCardNo)
print(res.json())
assert "200" == res.json()["code"], "正常获取客户信息获取失败"
assert "OK" == res.json()["message"], "正常获取客户信息获取失败"
# 使用副卡进行信息获取
# 副卡入库-出库-开卡
startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
endSlaveCardNo = startSlaveCardNo + 1
resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
endCardNo=endSlaveCardNo, cardType=20)
res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startSlaveCardNo,
cardType=20)
assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
amount = len([i for i in range(startSlaveCardNo, endSlaveCardNo + 1)])
outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
applyUserName=self.applyUserName, applyUserId=self.applyUserId,
applyUserCode=self.applyUserCode, amount=amount)
assert outCardRes.json()["code"] == "200", "出库失败"
resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
loginPwd=self.loginPwd, applyUserName=self.applyUserName,
parentLoginPwd=self.loginPwd)
assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
# 以上为测试准备
res = cC.getSimpleInfo(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startSlaveCardNo)
print(res.json())
assert "200" == res.json()["code"], "正常获取客户信息获取失败"
assert "OK" == res.json()["message"], "正常获取客户信息获取失败"
# 已挂失的卡片进行信息获取
# 已锁定的卡片进行信息获取
# 已冻结的卡片进行信息获取
# 副卡退卡
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
# 主卡退卡
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
def test_getChangeCardFee(self):
"""换卡工本费信息获取"""
res = cC.getChangeCardFee(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders)
print(res.json())
assert "200" == res.json()["code"], "正常获取客户信息获取失败"
assert "OK" == res.json()["message"], "正常获取客户信息获取失败"
def test_checkCorrectCard(self):
"""新卡卡状态校验"""
# 主卡入库-出库-开卡
faceNum = 1
startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
endCardNo = startCardNo + 1
resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
endCardNo=endCardNo, cardFace=cardFace)
print("resSavaCard.json() ->", resSavaCard.json())
cardNos = str(startCardNo) + "," + str(endCardNo)
print(cardNos)
amount = len([i for i in range(startCardNo, endCardNo)])
outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
applyUserName=self.applyUserName, applyUserId=self.applyUserId,
applyUserCode=self.applyUserCode, amount=amount)
assert outCardRes.json()["code"] == "200", "出库失败"
resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
print("resFirstOpen", resFirstOpen.json())
assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
# 副卡入库-出库-开卡
startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
endSlaveCardNo = startSlaveCardNo + 1
resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
endCardNo=endSlaveCardNo, cardType=20)
res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startSlaveCardNo,
cardType=20)
assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
amount = len([i for i in range(startSlaveCardNo, endSlaveCardNo + 1)])
outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
applyUserName=self.applyUserName, applyUserId=self.applyUserId,
applyUserCode=self.applyUserCode, amount=amount)
assert outCardRes.json()["code"] == "200", "出库失败"
resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
loginPwd=self.loginPwd, applyUserName=self.applyUserName,
parentLoginPwd=self.loginPwd)
assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
# 以上为测试数据准备
# 主卡校验
customerId = cC.getSimpleInfo(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,
cardNo=startCardNo).json()["data"]["accountInfo"]["customerId"]
print("customerId",customerId)
resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=endCardNo,customerId=customerId)
print(resCheckCard.json())
assert "200" == resCheckCard.json()["code"], "正常新主卡校验测试不通过"
assert "OK" == resCheckCard.json()["message"], "正常新主卡校验测试不通过"
assert str(endCardNo) in resCheckCard.text, "正常新主卡校验测试不通过"
# 副卡校验
resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=endSlaveCardNo,cardType=20,customerId=customerId)
print(resCheckCard.json())
assert "200" == resCheckCard.json()["code"], "正常新副卡校验测试不通过"
assert "OK" == resCheckCard.json()["message"], "正常新副卡校验测试不通过"
assert str(endSlaveCardNo) in resCheckCard.text, "正常新副卡校验测试不通过"
# 副卡退卡
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
# 主卡退卡
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
def test_checkErrorCard(self):
"""使用错误状态的卡片进行新卡校验"""
# 主卡入库-出库-开卡
faceNum = 1
startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
endCardNo = startCardNo + 2
resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
endCardNo=endCardNo, cardFace=cardFace)
print("resSavaCard.json() ->", resSavaCard.json())
cardNos = str(startCardNo) + "," + str(endCardNo)
print(cardNos)
amount = 2
outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
applyUserName=self.applyUserName, applyUserId=self.applyUserId,
applyUserCode=self.applyUserCode, amount=amount)
assert outCardRes.json()["code"] == "200", "出库失败"
resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
print("resFirstOpen", resFirstOpen.json())
assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
# 副卡入库-出库-开卡
startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
endSlaveCardNo = startSlaveCardNo + 2
resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
endCardNo=endSlaveCardNo, cardType=20)
res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startSlaveCardNo,
cardType=20)
assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
amount = 2
outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
applyUserName=self.applyUserName, applyUserId=self.applyUserId,
applyUserCode=self.applyUserCode, amount=amount)
assert outCardRes.json()["code"] == "200", "出库失败"
resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
loginPwd=self.loginPwd, applyUserName=self.applyUserName,
parentLoginPwd=self.loginPwd)
assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
# 开卡结束
customerId = cC.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startCardNo).json()["data"]["accountInfo"]["customerId"]
print("customerId", customerId)
# 以上为测试数据准备
"""开始测试"""
# 使用未出库的卡片进行校验
resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=999999999999,
customerId=customerId)
print("resCheckCard",resCheckCard.json())
assert "10000" == resCheckCard.json()["code"], "未入库卡片校验测试不通过"
assert "该卡未入库!" == resCheckCard.json()["message"], "未入库卡片校验测试不通过"
# 使用已作废的卡片进行校验
voidCardNo = startCardNo+1
resVoid = cS.cardVoid(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNo=voidCardNo)
assert resVoid.json()["code"] == "200", "新入库卡片作废测试失败"
resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=voidCardNo,
customerId=customerId)
print("resCheckCard",resCheckCard.json())
assert "20000" == resCheckCard.json()["code"], "[作废]卡片校验测试不通过"
assert "该卡状态为[作废],不能开卡!" == resCheckCard.json()["message"], "[作废]卡片校验测试不通过"
# 使用不匹配的卡面进行校验 -- 寿光市场
if self.firmId == 8:
pass
# 使用已开卡的主卡进行校验
resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cCNum=self.cCNum, cardNo=endCardNo, applyUserName=self.applyUserName)
print("resFirstOpen", resFirstOpen.json())
assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endCardNo,
customerId=customerId)
# print("resCheckCard",resCheckCard.json())
assert "20000" == resCheckCard.json()["code"], "正常新主卡校验测试不通过"
assert "该卡状态为[在用],不能开卡!" == resCheckCard.json()["message"], "正常新主卡校验测试不通过"
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endCardNo) #退卡
resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endCardNo,
customerId=customerId)
# 使用已退还的卡片可以进行换卡操作校验成功
# print("resCheckCard",resCheckCard.json())
assert "200" == resCheckCard.json()["code"], "已退还的主卡校验测试不通过"
assert "OK" == resCheckCard.json()["message"], "已退还的主卡校验测试不通过"
assert str(endCardNo) in resCheckCard.text, "已退还的主卡校验测试不通过"
# 主卡换卡时使用副卡校验
resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardType=10,cardNo=endSlaveCardNo,
customerId=customerId)
print("resCheckCard",resCheckCard.json())
assert "20000" == resCheckCard.json()["code"], "使用副卡对主卡进行换卡校验测试不通过"
assert "请使用主卡办理当前业务!" == resCheckCard.json()["message"], "使用副卡对主卡进行换卡校验测试不通过"
# 副卡换卡时使用主卡进行校验
resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardType=20,cardNo=endCardNo,
customerId=customerId)
print("resCheckCard",resCheckCard.json())
assert "20000" == resCheckCard.json()["code"], "副卡换卡时使用主卡进行校验测试不通过"
assert "请使用副卡办理当前业务!" == resCheckCard.json()["message"], "副卡换卡时使用主卡进行校验测试不通过"
# 使用未出库的副卡进行校验
resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=999999999999, cardType=20, customerId=customerId)
print(resCheckCard.json())
assert "10000" == resCheckCard.json()["code"], "未入库卡片校验测试不通过"
assert "该卡未入库!" == resCheckCard.json()["message"], "未入库卡片校验测试不通过"
# 使用已开卡的副卡进行校验
resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startCardNo, slaveCardNo=endSlaveCardNo,
loginPwd=self.loginPwd, applyUserName=self.applyUserName,
parentLoginPwd=self.loginPwd)
assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
resCheckCard = cC.checkCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=endSlaveCardNo, cardType=20, customerId=customerId)
print(resCheckCard.json())
assert "20000" == resCheckCard.json()["code"], "已开卡的卡片进行状态校验测试不通过"
assert "该卡状态为[在用],不能开卡!" == resCheckCard.json()["message"], "已开卡的卡片进行状态校验测试不通过"
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endSlaveCardNo)
"""测试完成"""
# 副卡退卡
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
# 主卡退卡
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)
def test_changeCard(self):
"""换卡正向流程测试"""
# 主卡入库-出库-开卡
faceNum = 1
startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
endCardNo = startCardNo + 2
resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
endCardNo=endCardNo, cardFace=cardFace)
print("resSavaCard.json() ->", resSavaCard.json())
cardNos = str(startCardNo) + "," + str(endCardNo)
amount = 2
outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
applyUserName=self.applyUserName, applyUserId=self.applyUserId,
applyUserCode=self.applyUserCode, amount=amount)
assert outCardRes.json()["code"] == "200", "出库失败"
resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
# 副卡入库-出库-开卡
startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
endSlaveCardNo = startSlaveCardNo + 2
resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
endCardNo=endSlaveCardNo, cardType=20)
res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startSlaveCardNo,
cardType=20)
assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
amount = 2
outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
applyUserName=self.applyUserName, applyUserId=self.applyUserId,
applyUserCode=self.applyUserCode, amount=amount)
assert outCardRes.json()["code"] == "200", "出库失败"
resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
loginPwd=self.loginPwd, applyUserName=self.applyUserName,
parentLoginPwd=self.loginPwd)
assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
# 开卡结束 --- > 获取卡账户信息,换卡工本费
serviceFee = cC.getChangeCardFee(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders).json()["data"]
# 以上为测试数据准备
"""开始测试"""
# 主卡换卡正常换卡测试 ---> 换卡成功后原卡片变为激活状态
resSimpleInfo = cC.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startCardNo)
customerId,accountId = resSimpleInfo.json()["data"]["accountInfo"]["customerId"],resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startCardNo,
newCardNo=endCardNo,serviceFee=serviceFee,loginPwd=self.loginPwd,accountId=accountId,customerId=customerId)
assert "200" == resChangeCard.json()["code"],"主卡换卡测试不通过"
assert "OK" == resChangeCard.json()["message"],"主卡换卡测试不通过"
resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders,cardNo=startCardNo)
assert "200" == resQuery.json()["code"], "查询失败"
assert "2" == str(resQuery.json()["rows"][0]["state"]),"状态查询成功"
# 副卡换卡正常换卡测试,换卡成功后原卡片变为激活状态
resSimpleInfo = cC.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startSlaveCardNo)
customerId,accountId = resSimpleInfo.json()["data"]["accountInfo"]["customerId"],resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startSlaveCardNo,
newCardNo=endSlaveCardNo, serviceFee=serviceFee, loginPwd=self.loginPwd,
accountId=accountId, customerId=customerId)
assert "200" == resChangeCard.json()["code"], "主卡换卡测试不通过"
assert "OK" == resChangeCard.json()["message"], "主卡换卡测试不通过"
resQuery = cS.queryCardStorageList(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNo=startSlaveCardNo)
assert "200" == resQuery.json()["code"], "查询失败"
assert "2" == str(resQuery.json()["rows"][0]["state"]), "状态查询成功"
"""测试完成"""
# 副卡退卡
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endSlaveCardNo)
# 主卡退卡
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endCardNo)
def test_changeCardError(self):
"""换卡正向流程测试"""
# 主卡入库-出库-开卡
faceNum = 1
startCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
endCardNo = startCardNo + 2
resCardFace = cSI.getCardFace(cardHost=self.cardHost, webHeaders=self.webHeaders)
cardFace = cSI.returnFaceValue(resCardFace=resCardFace, faceNum=faceNum)
resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startCardNo,
endCardNo=endCardNo, cardFace=cardFace)
print("resSavaCard.json() ->", resSavaCard.json())
cardNos = str(startCardNo) + "," + str(endCardNo)
amount = 2
outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=cardNos,
applyUserName=self.applyUserName, applyUserId=self.applyUserId,
applyUserCode=self.applyUserCode, amount=amount)
assert outCardRes.json()["code"] == "200", "出库失败"
resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cCNum=self.cCNum, cardNo=startCardNo, applyUserName=self.applyUserName)
assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
resFirstOpen = oMC.openMasterCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cCNum=self.cCNum, cardNo=endCardNo, applyUserName=self.applyUserName)
assert "200" == resFirstOpen.json()["code"], "第一次开卡,开卡失败"
assert "data" in resFirstOpen.json(), "第一次开卡,开卡失败"
# 副卡入库-出库-开卡
startSlaveCardNo = int(time.strftime("%y%m%d%H%M%S", time.localtime()))
endSlaveCardNo = startSlaveCardNo + 2
resSavaCard = cSI.savaCard(cardHost=self.cardHost, webHeaders=self.webHeaders, startCardNo=startSlaveCardNo,
endCardNo=endSlaveCardNo, cardType=20)
res = oMC.checkNewCardNo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startSlaveCardNo,
cardType=20)
assert "20000" == res.json()["code"], "使用已存在未出库的卡片进行校验校验失败"
assert "该卡状态为[未激活],不能开卡!" == res.json()["message"], "message信息与预期信息不匹配"
slaveCardNos = str(startSlaveCardNo) + "," + str(endSlaveCardNo)
amount = 2
outCardRes = cSO.cardAddOut(cardHost=self.cardHost, webHeaders=self.webHeaders, cardNos=slaveCardNos,
applyUserName=self.applyUserName, applyUserId=self.applyUserId,
applyUserCode=self.applyUserCode, amount=amount)
assert outCardRes.json()["code"] == "200", "出库失败"
resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startCardNo, slaveCardNo=startSlaveCardNo,
loginPwd=self.loginPwd, applyUserName=self.applyUserName,
parentLoginPwd=self.loginPwd)
assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
resOpenSlaveCard = oMC.openSlaveCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startCardNo, slaveCardNo=endSlaveCardNo,
loginPwd=self.loginPwd, applyUserName=self.applyUserName,
parentLoginPwd=self.loginPwd)
assert "200" == resOpenSlaveCard.json()["code"], "开卡测试失败"
# 开卡结束 --- > 获取卡账户信息,换卡工本费
serviceFee = cC.getChangeCardFee(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders).json()["data"]
resSimpleInfo = cC.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startCardNo)
customerId,accountId = resSimpleInfo.json()["data"]["accountInfo"]["customerId"],resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
resSimpleInfo = cC.getSimpleInfo(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startSlaveCardNo)
customerIdSlaveCard,accountIdSlaveCard = resSimpleInfo.json()["data"]["accountInfo"]["customerId"],resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
# 以上为测试数据准备
"""开始测试"""
# 使用未入库的主卡卡片和副卡进行换卡
resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startCardNo,
newCardNo=999999999999,serviceFee=serviceFee,loginPwd=self.loginPwd,accountId=accountId,customerId=customerId)
assert "10000" == resChangeCard.json()["code"],"主卡换卡测试不通过"
assert "该卡未入库!" == resChangeCard.json()["message"],"主卡换卡测试不通过"
resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startSlaveCardNo,
newCardNo=999999999999,serviceFee=serviceFee,loginPwd=self.loginPwd,
accountId=accountIdSlaveCard,customerId=customerIdSlaveCard)
assert "10000" == resChangeCard.json()["code"],"副卡换卡测试不通过"
assert "该卡未入库!" == resChangeCard.json()["message"],"副卡换卡测试不通过"
# 使用未出库的主卡卡片和副卡进行换卡
resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startCardNo,
newCardNo=startCardNo+1,serviceFee=serviceFee,loginPwd=self.loginPwd,accountId=accountId,customerId=customerId)
print(resChangeCard.json())
assert "20000" == resChangeCard.json()["code"],"使用未出库的主卡换卡测试不通过"
assert "该卡状态为[未激活],不能开卡!" == resChangeCard.json()["message"],"使用未出库的主卡换卡测试不通过"
resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost,clientHeaders=self.clientHeaders,cardNo=startSlaveCardNo,
newCardNo=startSlaveCardNo+1,serviceFee=serviceFee,loginPwd=self.loginPwd,
accountId=accountIdSlaveCard,customerId=customerIdSlaveCard)
print(resChangeCard.json())
assert "20000" == resChangeCard.json()["code"],"使用未出库的副卡换卡测试不通过"
assert "该卡状态为[未激活],不能开卡!" == resChangeCard.json()["message"],"使用未出库的副卡换卡测试不通过"
# 使用已开卡的主卡卡片和副卡进行换卡
resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startCardNo,
newCardNo=endCardNo, serviceFee=serviceFee, loginPwd=self.loginPwd,
accountId=accountId, customerId=customerId)
print(resChangeCard.json())
assert "20000" == resChangeCard.json()["code"], "主卡换卡测试不通过"
assert "该卡状态为[在用],不能开卡!" == resChangeCard.json()["message"], " 使用已开卡的主卡换卡测试不通过"
resChangeCard = cC.changeCard(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders,
cardNo=startSlaveCardNo,
newCardNo=endSlaveCardNo, serviceFee=serviceFee, loginPwd=self.loginPwd,
accountId=accountIdSlaveCard, customerId=customerIdSlaveCard)
print(resChangeCard.json())
assert "20000" == resChangeCard.json()["code"], "副卡换卡测试不通过"
assert "该卡状态为[在用],不能开卡!" == resChangeCard.json()["message"], " 使用已开卡的副卡换卡测试不通过"
"""测试完成"""
# 副卡退卡
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endSlaveCardNo)
# 副卡退卡
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startSlaveCardNo)
# 主卡退卡
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=endCardNo)
# 主卡退卡
reC.returnCardDef(gatewayHost=self.gatewayHost, clientHeaders=self.clientHeaders, cardNo=startCardNo)