Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit a6454a2

Browse files
committed
Update qa tests to parse responses by version
1 parent 2452072 commit a6454a2

26 files changed

+261
-41
lines changed

qa/cancel_direct_offline.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ def run_test(self):
3838
# post listing to alice
3939
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
4040
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
41-
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
4241
listing_json["metadata"]["acceptedCurrencies"] = ["t" + self.cointype]
42+
if self.vendor_version == 4:
43+
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
44+
else:
45+
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
46+
4347
api_url = alice["gateway_url"] + "ob/listing"
4448
r = requests.post(api_url, data=json.dumps(listing_json, indent=4))
4549
if r.status_code == 404:
@@ -104,6 +108,10 @@ def run_test(self):
104108
"feeLevel": "NORMAL",
105109
"requireAssociateOrder": False
106110
}
111+
if self.buyer_version == 4:
112+
spend["amount"] = payment_amount
113+
spend["wallet"] = "T" + self.cointype
114+
107115
api_url = bob["gateway_url"] + "wallet/spend"
108116
r = requests.post(api_url, data=json.dumps(spend, indent=4))
109117
if r.status_code == 404:
@@ -169,8 +177,12 @@ def run_test(self):
169177
resp = json.loads(r.text)
170178
confirmed = int(resp["confirmed"])
171179
#unconfirmed = int(resp["unconfirmed"])
172-
if confirmed <= 50 - int(payment_amount["amount"]):
173-
raise TestFailure("CancelDirectOfflineTest - FAIL: Bob failed to receive the multisig payout")
180+
if self.buyer_version == 4:
181+
if confirmed <= 50 - payment_amount:
182+
raise TestFailure("CancelDirectOfflineTest - FAIL: Bob failed to receive the multisig payout")
183+
else:
184+
if confirmed <= 50 - int(payment_amount["amount"]):
185+
raise TestFailure("CancelDirectOfflineTest - FAIL: Bob failed to receive the multisig payout")
174186
else:
175187
raise TestFailure("CancelDirectOfflineTest - FAIL: Failed to query Bob's balance")
176188

qa/complete_direct_online.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ def run_test(self):
3838
# post listing to alice
3939
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
4040
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
41-
listing_json["item"]["priceCurrency"]["code"] = "T" + self.cointype
4241
listing_json["metadata"]["acceptedCurrencies"] = ["T" + self.cointype]
42+
if self.vendor_version == 4:
43+
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
44+
else:
45+
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
46+
4347
api_url = alice["gateway_url"] + "ob/listing"
4448
r = requests.post(api_url, data=json.dumps(listing_json, indent=4))
4549
if r.status_code == 404:
@@ -106,6 +110,10 @@ def run_test(self):
106110
"feeLevel": "NORMAL",
107111
"requireAssociateOrder": False
108112
}
113+
if self.buyer_version == 4:
114+
spend["amount"] = payment_amount
115+
spend["wallet"] = "T" + self.cointype
116+
109117
api_url = bob["gateway_url"] + "wallet/spend"
110118
r = requests.post(api_url, data=json.dumps(spend, indent=4))
111119
if r.status_code == 404:

qa/complete_disputed.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ def run_test(self):
6464
# post listing to alice
6565
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
6666
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
67-
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
6867
listing_json["metadata"]["acceptedCurrencies"] = ["t" + self.cointype]
68+
if self.vendor_version == 4:
69+
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
70+
else:
71+
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
72+
6973
listing_json["moderators"] = [moderatorId]
7074
api_url = alice["gateway_url"] + "ob/listing"
7175
r = requests.post(api_url, data=json.dumps(listing_json, indent=4))
@@ -135,6 +139,10 @@ def run_test(self):
135139
"feeLevel": "NORMAL",
136140
"requireAssociateOrder": False
137141
}
142+
if self.buyer_version == 4:
143+
spend["amount"] = payment_amount
144+
spend["wallet"] = "T" + self.cointype
145+
138146
api_url = bob["gateway_url"] + "wallet/spend"
139147
r = requests.post(api_url, data=json.dumps(spend, indent=4))
140148
if r.status_code == 404:
@@ -288,7 +296,12 @@ def run_test(self):
288296
resp = json.loads(r.text)
289297
confirmed = int(resp["confirmed"])
290298
#unconfirmed = int(resp["unconfirmed"])
291-
if confirmed <= (generated_coins*100000000) - int(payment_amount["amount"]):
299+
amt = 0
300+
if self.buyer_version == 4:
301+
amt = payment_amount
302+
else:
303+
amt = int(payment_amount["amount"])
304+
if confirmed <= (generated_coins*100000000) - amt:
292305
raise TestFailure("CompleteDisputedTest - FAIL: Bob failed to detect dispute payout")
293306
elif r.status_code == 404:
294307
raise TestFailure("CompleteDisputedTest - FAIL: Receive coins endpoint not found")

qa/complete_moderated_online.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ def run_test(self):
6363
# post listing to alice
6464
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
6565
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
66-
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
66+
if self.vendor_version == 4:
67+
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
68+
else:
69+
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
6770
listing_json["metadata"]["acceptedCurrencies"] = ["t" + self.cointype]
6871
slug = listing_json["slug"]
6972
listing_json["moderators"] = [moderatorId]
@@ -135,6 +138,10 @@ def run_test(self):
135138
"feeLevel": "NORMAL",
136139
"requireAssociateOrder": False
137140
}
141+
if self.buyer_version == 4:
142+
spend["amount"] = payment_amount
143+
spend["wallet"] = "T" + self.cointype
144+
138145
api_url = bob["gateway_url"] + "wallet/spend"
139146
r = requests.post(api_url, data=json.dumps(spend, indent=4))
140147
if r.status_code == 404:

qa/complete_moderated_with_timeout.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ def run_test(self):
6363
# post listing to alice
6464
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
6565
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
66-
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
66+
if self.vendor_version == 4:
67+
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
68+
else:
69+
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
6770
listing_json["metadata"]["acceptedCurrencies"] = ["t" + self.cointype]
6871
slug = listing_json["slug"]
6972
listing_json["moderators"] = [moderatorId]
@@ -136,6 +139,10 @@ def run_test(self):
136139
"feeLevel": "NORMAL",
137140
"requireAssociateOrder": False
138141
}
142+
if self.buyer_version == 4:
143+
spend["amount"] = payment_amount
144+
spend["wallet"] = "T" + self.cointype
145+
139146
api_url = bob["gateway_url"] + "wallet/spend"
140147
r = requests.post(api_url, data=json.dumps(spend, indent=4))
141148
if r.status_code == 404:

qa/dispute_close_buyer.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ def run_test(self):
6464
# post listing to alice
6565
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
6666
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
67-
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
67+
if self.vendor_version == 4:
68+
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
69+
else:
70+
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
6871
listing_json["metadata"]["acceptedCurrencies"] = ["t" + self.cointype]
6972

7073
listing_json["moderators"] = [moderatorId]
@@ -134,6 +137,10 @@ def run_test(self):
134137
"feeLevel": "NORMAL",
135138
"requireAssociateOrder": False
136139
}
140+
if self.buyer_version == 4:
141+
spend["amount"] = payment_amount
142+
spend["wallet"] = "T" + self.cointype
143+
137144
api_url = bob["gateway_url"] + "wallet/spend"
138145
r = requests.post(api_url, data=json.dumps(spend, indent=4))
139146
if r.status_code == 404:
@@ -273,7 +280,12 @@ def run_test(self):
273280
resp = json.loads(r.text)
274281
confirmed = int(resp["confirmed"])
275282
#unconfirmed = int(resp["unconfirmed"])
276-
if confirmed <= (generated_coins*100000000) - int(payment_amount["amount"]):
283+
amt = 0
284+
if self.buyer_version == 4:
285+
amt = payment_amount
286+
else:
287+
amt = int(payment_amount["amount"])
288+
if confirmed <= (generated_coins*100000000) - amt:
277289
raise TestFailure("DisputeCloseBuyerTest - FAIL: Bob failed to detect dispute payout")
278290
elif r.status_code == 404:
279291
raise TestFailure("DisputeCloseBuyerTest - FAIL: Receive coins endpoint not found")

qa/dispute_close_split.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ def run_test(self):
6464
# post listing to alice
6565
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
6666
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
67-
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
67+
if self.vendor_version == 4:
68+
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
69+
else:
70+
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
6871
listing_json["metadata"]["acceptedCurrencies"] = ["t" + self.cointype]
6972

7073
listing_json["moderators"] = [moderatorId]
@@ -134,6 +137,10 @@ def run_test(self):
134137
"feeLevel": "NORMAL",
135138
"requireAssociateOrder": False
136139
}
140+
if self.buyer_version == 4:
141+
spend["amount"] = payment_amount
142+
spend["wallet"] = "T" + self.cointype
143+
137144
api_url = bob["gateway_url"] + "wallet/spend"
138145
r = requests.post(api_url, data=json.dumps(spend, indent=4))
139146
if r.status_code == 404:
@@ -273,7 +280,13 @@ def run_test(self):
273280
resp = json.loads(r.text)
274281
confirmed = int(resp["confirmed"])
275282
unconfirmed = int(resp["unconfirmed"])
276-
if confirmed + unconfirmed <= (generated_coins*100000000) - int(payment_amount["amount"]):
283+
amt = 0
284+
if self.buyer_version == 4:
285+
amt = payment_amount
286+
else:
287+
amt = int(payment_amount["amount"])
288+
289+
if confirmed + unconfirmed <= (generated_coins*100000000) - amt:
277290
raise TestFailure("DisputeCloseSplitTest - FAIL: Bob failed to detect dispute payout")
278291
elif r.status_code == 404:
279292
raise TestFailure("DisputeCloseSplitTest - FAIL: Receive coins endpoint not found")

qa/dispute_close_vendor.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ def run_test(self):
6464
# post listing to alice
6565
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
6666
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
67-
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
67+
if self.vendor_version == 4:
68+
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
69+
else:
70+
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
6871
listing_json["metadata"]["acceptedCurrencies"] = ["t" + self.cointype]
6972

7073
listing_json["moderators"] = [moderatorId]
@@ -136,6 +139,10 @@ def run_test(self):
136139
"feeLevel": "NORMAL",
137140
"requireAssociateOrder": False
138141
}
142+
if self.buyer_version == 4:
143+
spend["amount"] = payment_amount
144+
spend["wallet"] = "T" + self.cointype
145+
139146
api_url = bob["gateway_url"] + "wallet/spend"
140147
r = requests.post(api_url, data=json.dumps(spend, indent=4))
141148
if r.status_code == 404:

qa/escrow_release_after_timeout.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ def run_test(self):
6363
# post listing to alice
6464
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
6565
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
66-
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
66+
if self.vendor_version == 4:
67+
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
68+
else:
69+
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
6770
listing_json["metadata"]["acceptedCurrencies"] = ["t" + self.cointype]
6871
slug = listing_json["slug"]
6972
listing_json["moderators"] = [moderatorId]
@@ -136,6 +139,10 @@ def run_test(self):
136139
"feeLevel": "NORMAL",
137140
"requireAssociateOrder": False
138141
}
142+
if self.buyer_version == 4:
143+
spend["amount"] = payment_amount
144+
spend["wallet"] = "T" + self.cointype
145+
139146
api_url = bob["gateway_url"] + "wallet/spend"
140147
r = requests.post(api_url, data=json.dumps(spend, indent=4))
141148
if r.status_code == 404:

qa/fulfill_direct_online.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ def run_test(self):
3838
# post listing to alice
3939
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
4040
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
41-
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
41+
if self.vendor_version == 4:
42+
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
43+
else:
44+
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
4245
listing_json["metadata"]["acceptedCurrencies"] = ["t" + self.cointype]
4346

4447
api_url = alice["gateway_url"] + "ob/listing"
@@ -107,6 +110,10 @@ def run_test(self):
107110
"feeLevel": "NORMAL",
108111
"requireAssociateOrder": False
109112
}
113+
if self.buyer_version == 4:
114+
spend["amount"] = payment_amount
115+
spend["wallet"] = "T" + self.cointype
116+
110117
api_url = bob["gateway_url"] + "wallet/spend"
111118
r = requests.post(api_url, data=json.dumps(spend, indent=4))
112119
if r.status_code == 404:

0 commit comments

Comments
 (0)