-
Notifications
You must be signed in to change notification settings - Fork 21
/
run_all.py
51 lines (47 loc) · 2.32 KB
/
run_all.py
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
import time
from create_payouts import CreatePayouts
from get_payouts import GetPayouts
from get_payout_item import GetPayoutItem
from cancel_payout_item import CancelPayoutItem
print('Creating Payouts')
create_response = CreatePayouts().create_payouts(True)
if create_response.status_code == 201:
batch_id = create_response.result.batch_header.payout_batch_id
print('Retrieving Payouts batch with id: ' + batch_id)
get_response = GetPayouts().get_payouts(batch_id, True)
if get_response.status_code == 200:
item_id = get_response.result.items[0].payout_item_id
print('Retrieving Payout item with id: ' + item_id)
get_item_response = GetPayoutItem().get_payout_item(item_id, True)
if get_item_response.status_code == 200:
print(
'Check Payouts status to see if it has completed processing all payments')
for i in range(5):
time.sleep(2)
get_response = GetPayouts().get_payouts(batch_id, True)
if get_response.result.batch_header.batch_status == "SUCCESS":
print('Cancelling unclaimed payout item with id: ' + item_id)
cancel_response = CancelPayoutItem().cancel_payout_item(item_id, True)
if cancel_response.status_code == 200:
print(
'Successfully cancelled unclaimed payout item with id: ' + item_id)
# Run cancel failure scenario
print('Simulate failure on cancelling an already cancelled Payout item with id: ' + item_id)
CancelPayoutItem().cancel_payout_item(item_id, True)
else:
print(
'Failed to cancel unclaimed payout item with id: ' + item_id)
break
if i == 4:
print('Payouts batch is not processed yet')
else:
print('Failed to retrieve Payouts batch with id: ' + batch_id)
else:
print('Failed to create Payouts batch')
# Execute all failure cases
print('Create a payout with validation failure')
CreatePayouts().create_payouts_failure(True)
print('Retrieving an invalid payout')
GetPayouts().get_payouts("DUMMY", True)
print('Retrieving an invalid payout item')
GetPayoutItem().get_payout_item("DUMMY", True)