Wait until the expected result is fetched in Stripe test scenario
Closes #12221
This commit is contained in:
@@ -18,7 +18,7 @@ Imports::
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
>>> FETCH_SLEEP = 1
|
||||
>>> FETCH_SLEEP, MAX_SLEEP = 1, 10
|
||||
|
||||
Activate modules::
|
||||
|
||||
@@ -121,9 +121,12 @@ Process the payment::
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
>>> time.sleep(FETCH_SLEEP)
|
||||
>>> cron_fetch_events.click('run_once')
|
||||
>>> payment.reload()
|
||||
>>> for _ in range(MAX_SLEEP):
|
||||
... cron_fetch_events.click('run_once')
|
||||
... payment.reload()
|
||||
... if payment.state == 'succeeded':
|
||||
... break
|
||||
... time.sleep(FETCH_SLEEP)
|
||||
>>> payment.state
|
||||
'succeeded'
|
||||
>>> bool(payment.stripe_captured)
|
||||
@@ -226,9 +229,12 @@ Make payment with customer::
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
>>> time.sleep(FETCH_SLEEP)
|
||||
>>> cron_fetch_events.click('run_once')
|
||||
>>> payment.reload()
|
||||
>>> for _ in range(MAX_SLEEP):
|
||||
... cron_fetch_events.click('run_once')
|
||||
... payment.reload()
|
||||
... if payment.state == 'succeeded':
|
||||
... break
|
||||
... time.sleep(FETCH_SLEEP)
|
||||
>>> payment.state
|
||||
'succeeded'
|
||||
|
||||
@@ -300,9 +306,12 @@ Capture lower amount::
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
>>> time.sleep(FETCH_SLEEP)
|
||||
>>> cron_fetch_events.click('run_once')
|
||||
>>> payment.reload()
|
||||
>>> for _ in range(MAX_SLEEP):
|
||||
... cron_fetch_events.click('run_once')
|
||||
... payment.reload()
|
||||
... if payment.state == 'succeeded':
|
||||
... break
|
||||
... time.sleep(FETCH_SLEEP)
|
||||
>>> payment.state
|
||||
'succeeded'
|
||||
>>> bool(payment.stripe_captured)
|
||||
@@ -320,10 +329,13 @@ Refund some amount::
|
||||
... ('method', '=', 'account.payment.stripe.refund|stripe_create'),
|
||||
... ])
|
||||
>>> cron_refund_create.click('run_once')
|
||||
>>> time.sleep(FETCH_SLEEP)
|
||||
>>> cron_fetch_events.click('run_once')
|
||||
|
||||
>>> payment.reload()
|
||||
>>> for _ in range(MAX_SLEEP):
|
||||
... cron_fetch_events.click('run_once')
|
||||
... payment.reload()
|
||||
... if payment.amount == Decimal('2.00'):
|
||||
... break
|
||||
... time.sleep(FETCH_SLEEP)
|
||||
>>> payment.amount
|
||||
Decimal('2.00')
|
||||
>>> payment.state
|
||||
@@ -340,10 +352,13 @@ Simulate charge.refunded event with full amount::
|
||||
>>> refund.click('submit')
|
||||
>>> refund.click('approve')
|
||||
>>> cron_refund_create.click('run_once')
|
||||
>>> time.sleep(FETCH_SLEEP)
|
||||
>>> cron_fetch_events.click('run_once')
|
||||
|
||||
>>> payment.reload()
|
||||
>>> for _ in range(MAX_SLEEP):
|
||||
... cron_fetch_events.click('run_once')
|
||||
... payment.reload()
|
||||
... if payment.amount == Decimal('0.00'):
|
||||
... break
|
||||
... time.sleep(FETCH_SLEEP)
|
||||
>>> payment.amount
|
||||
Decimal('0.00')
|
||||
>>> payment.state
|
||||
@@ -360,8 +375,12 @@ Try to refund more::
|
||||
>>> refund.click('submit')
|
||||
>>> refund.click('approve')
|
||||
>>> cron_refund_create.click('run_once')
|
||||
>>> time.sleep(FETCH_SLEEP)
|
||||
>>> cron_fetch_events.click('run_once')
|
||||
>>> refund.reload()
|
||||
|
||||
>>> for _ in range(MAX_SLEEP):
|
||||
... cron_fetch_events.click('run_once')
|
||||
... refund.reload()
|
||||
... if refund.state == 'failed':
|
||||
... break
|
||||
... time.sleep(FETCH_SLEEP)
|
||||
>>> refund.state
|
||||
'failed'
|
||||
|
||||
@@ -18,7 +18,7 @@ Imports::
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
>>> FETCH_SLEEP = 1
|
||||
>>> FETCH_SLEEP, MAX_SLEEP = 1, 10
|
||||
|
||||
Activate modules::
|
||||
|
||||
@@ -104,9 +104,12 @@ Create fully disputed payment::
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
>>> time.sleep(FETCH_SLEEP)
|
||||
>>> cron_fetch_events.click('run_once')
|
||||
>>> payment.reload()
|
||||
>>> for _ in range(MAX_SLEEP):
|
||||
... cron_fetch_events.click('run_once')
|
||||
... payment.reload()
|
||||
... if payment.state == 'succeeded':
|
||||
... break
|
||||
... time.sleep(FETCH_SLEEP)
|
||||
>>> payment.state
|
||||
'succeeded'
|
||||
>>> bool(payment.stripe_captured)
|
||||
@@ -195,9 +198,12 @@ Create partial disputed payment::
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
>>> time.sleep(FETCH_SLEEP)
|
||||
>>> cron_fetch_events.click('run_once')
|
||||
>>> payment.reload()
|
||||
>>> for _ in range(MAX_SLEEP):
|
||||
... cron_fetch_events.click('run_once')
|
||||
... payment.reload()
|
||||
... if payment.state == 'succeeded':
|
||||
... break
|
||||
... time.sleep(FETCH_SLEEP)
|
||||
>>> payment.state
|
||||
'succeeded'
|
||||
>>> bool(payment.stripe_captured)
|
||||
@@ -264,9 +270,12 @@ Create won disputed payment::
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
>>> time.sleep(FETCH_SLEEP)
|
||||
>>> cron_fetch_events.click('run_once')
|
||||
>>> payment.reload()
|
||||
>>> for _ in range(MAX_SLEEP):
|
||||
... cron_fetch_events.click('run_once')
|
||||
... payment.reload()
|
||||
... if payment.state == 'succeeded':
|
||||
... break
|
||||
... time.sleep(FETCH_SLEEP)
|
||||
>>> payment.state
|
||||
'succeeded'
|
||||
>>> bool(payment.stripe_captured)
|
||||
@@ -278,9 +287,12 @@ Simulate charge.dispute.closed event::
|
||||
>>> dispute = stripe.Dispute.modify(charge.dispute,
|
||||
... evidence={'uncategorized_text': 'winning_evidence'})
|
||||
|
||||
>>> time.sleep(FETCH_SLEEP)
|
||||
>>> cron_fetch_events.click('run_once')
|
||||
>>> payment.reload()
|
||||
>>> for _ in range(MAX_SLEEP):
|
||||
... cron_fetch_events.click('run_once')
|
||||
... payment.reload()
|
||||
... if payment.state == 'succeeded':
|
||||
... break
|
||||
... time.sleep(FETCH_SLEEP)
|
||||
>>> payment.state
|
||||
'succeeded'
|
||||
>>> payment.amount
|
||||
|
||||
@@ -18,7 +18,7 @@ Imports::
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
>>> FETCH_SLEEP = 1
|
||||
>>> FETCH_SLEEP, MAX_SLEEP = 1, 10
|
||||
|
||||
Activate modules::
|
||||
|
||||
@@ -121,9 +121,12 @@ Process off-session the payment::
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
>>> time.sleep(FETCH_SLEEP)
|
||||
>>> cron_fetch_events.click('run_once')
|
||||
>>> payment.reload()
|
||||
>>> for _ in range(MAX_SLEEP):
|
||||
... cron_fetch_events.click('run_once')
|
||||
... payment.reload()
|
||||
... if payment.state == 'succeeded':
|
||||
... break
|
||||
... time.sleep(FETCH_SLEEP)
|
||||
>>> payment.state
|
||||
'succeeded'
|
||||
>>> bool(payment.stripe_captured)
|
||||
@@ -142,9 +145,12 @@ Refund the payment::
|
||||
... ])
|
||||
>>> cron_refund_create.click('run_once')
|
||||
|
||||
>>> time.sleep(FETCH_SLEEP)
|
||||
>>> cron_fetch_events.click('run_once')
|
||||
>>> payment.reload()
|
||||
>>> for _ in range(MAX_SLEEP):
|
||||
... cron_fetch_events.click('run_once')
|
||||
... payment.reload()
|
||||
... if payment.state == 'failed':
|
||||
... break
|
||||
... time.sleep(FETCH_SLEEP)
|
||||
>>> payment.state
|
||||
'failed'
|
||||
|
||||
@@ -169,8 +175,11 @@ Cancel payment intent::
|
||||
|
||||
>>> _ = stripe.PaymentIntent.cancel(payment.stripe_payment_intent_id)
|
||||
|
||||
>>> time.sleep(FETCH_SLEEP)
|
||||
>>> cron_fetch_events.click('run_once')
|
||||
>>> payment.reload()
|
||||
>>> for _ in range(MAX_SLEEP):
|
||||
... cron_fetch_events.click('run_once')
|
||||
... payment.reload()
|
||||
... if payment.state == 'failed':
|
||||
... break
|
||||
... time.sleep(FETCH_SLEEP)
|
||||
>>> payment.state
|
||||
'failed'
|
||||
|
||||
Reference in New Issue
Block a user