Skip to content

Commit 9c8a565

Browse files
committed
Testing: Add addPayment action to order testing backend
1 parent 989a60a commit 9c8a565

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ x.x.x (unreleased)
66
- Improved error information in CommercetoolsError object
77
- Testing: Add setAttribute and addVariant actions to product testing backend
88
- Testing: Add addAttributeDefinition action to testing backend
9+
- Testing: Add addPayment action to order testing backend
910
- Testing: Check for unique values in testing backend
1011
- Testing: Fixed Attribute return object in ProductTypes testing backend
1112

src/commercetools/testing/orders.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ def updater(self, obj, action):
7575
return updater
7676

7777

78+
def add_payment():
79+
def updater(self, obj, action):
80+
obj = copy.deepcopy(obj)
81+
if "paymentInfo" in obj and obj["paymentInfo"]:
82+
payments = obj["paymentInfo"]["payments"]
83+
else:
84+
payments = []
85+
86+
payments.append(schemas.PaymentReferenceSchema().dump(action.payment))
87+
obj["paymentInfo"] = {"payments": payments}
88+
return obj
89+
90+
return updater
91+
92+
7893
class OrdersBackend(ServiceBackend):
7994
service_path = "orders"
8095
model_class = OrdersModel
@@ -102,4 +117,5 @@ def urls(self):
102117
"setBillingAddress": update_attribute("billingAddress", "address"),
103118
"setCustomerEmail": update_attribute("customerEmail", "email"),
104119
"setCustomField": set_custom_field(),
120+
"addPayment": add_payment(),
105121
}

0 commit comments

Comments
 (0)