details:   https://code.tryton.org/tryton/commit/a1cb164af115
branch:    default
user:      Cédric Krier <[email protected]>
date:      Thu Jun 25 19:03:12 2026 +0200
description:
        Retry mutation query for Shopify tests
diffstat:

 modules/web_shop_shopify/tests/tools.py |  21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diffs (87 lines):

diff -r f209a22166ee -r a1cb164af115 modules/web_shop_shopify/tests/tools.py
--- a/modules/web_shop_shopify/tests/tools.py   Mon Jun 29 18:07:05 2026 +0200
+++ b/modules/web_shop_shopify/tests/tools.py   Thu Jun 25 19:03:12 2026 +0200
@@ -1,6 +1,9 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 
+import time
+from functools import wraps
+
 from shopify_app import admin_graphql_request
 
 from trytond.modules.web_shop_shopify import SHOPIFY_VERSION
@@ -8,6 +11,17 @@
 from trytond.modules.web_shop_shopify.exceptions import GraphQLException
 
 
+def retry(func):
+    @wraps(func)
+    def wrapper(*args, **kwargs):
+        for _ in range(10):
+            try:
+                return func(*args, **kwargs)
+            except Exception:
+                time.sleep(1)
+    return wrapper
+
+
 def shopify_request(shop, query, variables=None, user_errors=None):
     result = admin_graphql_request(
         query=query,
@@ -76,6 +90,7 @@
             }).data['product']
 
 
+@retry
 def delete_product(shop, id):
     shopify_request(shop, '''mutation productDelete($id: ID!) {
         productDelete(input: {id: $id}) {
@@ -90,6 +105,7 @@
         user_errors='productDelete.userErrors')
 
 
+@retry
 def delete_collection(shop, id):
     shopify_request(shop, '''mutation collectionDelete($id: ID!) {
         collectionDelete(input: {id: $id}) {
@@ -104,6 +120,7 @@
         user_errors='collectionDelete.userErrors')
 
 
+@retry
 def create_customer(shop, customer):
     return shopify_request(shop, '''mutation customerCreate(
     $input: CustomerInput!) {
@@ -123,6 +140,7 @@
         ).data['customerCreate']['customer']
 
 
+@retry
 def delete_customer(shop, id):
     shopify_request(shop, '''mutation customerDelete($id: ID!) {
         customerDelete(input: {id: $id}) {
@@ -137,6 +155,7 @@
         user_errors='customerDelete.userErrors')
 
 
+@retry
 def create_order(shop, order):
     return shopify_request(shop, '''mutation orderCreate(
     $order: OrderCreateOrderInput!) {
@@ -201,6 +220,7 @@
             }).data['order']
 
 
+@retry
 def capture_order(shop, id, amount, parent_transaction_id):
     return shopify_request(shop, '''mutation orderCapture(
     $input: OrderCaptureInput!) {
@@ -224,6 +244,7 @@
         ).data['orderCapture']['transaction']
 
 
+@retry
 def delete_order(shop, id):
     shopify_request(shop, '''mutation orderDelete($orderId: ID!) {
         orderDelete(orderId: $orderId) {

Reply via email to