Wait until the expected result is fetched in Shopify test scenario

Closes #12794
(grafted from dd11633bfa87f06b7c7f18a8bd444cb468582da2)

--HG--
branch : 7.0
This commit is contained in:
Cédric Krier
2023-12-02 12:02:16 +01:00
parent 681a0247ab
commit bb82a8d1f6
2 changed files with 15 additions and 3 deletions
@@ -24,6 +24,8 @@ Imports::
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> FETCH_SLEEP, MAX_SLEEP = 1, 10
Activate modules::
>>> config = activate_modules([
@@ -358,7 +360,11 @@ Check inventory item::
>>> inventory_items = ProductInventoryItem.find([])
>>> inventory_item_ids = [i.shopify_identifier
... for inv in inventory_items for i in inv.shopify_identifiers]
>>> inventory_levels = location.inventory_levels()
>>> for _ in range(MAX_SLEEP):
... inventory_levels = location.inventory_levels()
... if inventory_levels:
... break
... time.sleep(FETCH_SLEEP)
>>> sorted(l.available for l in inventory_levels
... if l.available and l.inventory_item_id in inventory_item_ids)
[5, 10]
@@ -627,7 +633,7 @@ Clean up::
>>> for category in ShopifyIdentifier.find(
... [('record', 'like', 'product.category,%')]):
... shopify.CustomCollection.find(category.shopify_identifier).destroy()
>>> time.sleep(1)
>>> time.sleep(FETCH_SLEEP)
>>> customer.destroy()
>>> shopify.ShopifyResource.clear_session()
@@ -24,6 +24,8 @@ Imports::
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> FETCH_SLEEP, MAX_SLEEP = 1, 10
Activate modules::
>>> config = activate_modules([
@@ -190,7 +192,11 @@ Run fetch order::
... cron_fetch_order, = Cron.find([
... ('method', '=', 'web.shop|shopify_fetch_order'),
... ])
... cron_fetch_order.click('run_once')
... for _ in range(MAX_SLEEP):
... cron_fetch_order.click('run_once')
... if Sale.find([]):
... break
... time.sleep(FETCH_SLEEP)
>>> sale, = Sale.find([])
>>> len(sale.lines)