Skip to content

Commit 15e045d

Browse files
committed
Add support for updating product type sets in the mock server
1 parent 97d7fe4 commit 15e045d

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/commercetools/testing/product_types.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,22 @@ def updater(
7272
):
7373
new = copy.deepcopy(obj)
7474

75+
def update_attribute_type(type_info: dict):
76+
if type_info["name"] == "lenum":
77+
for value in type_info["values"]:
78+
if value["key"] == action.new_value.key:
79+
value["label"] = action.new_value.label
80+
return new
81+
82+
if type_info["name"] == "set":
83+
return update_attribute_type(type_info["elementType"])
84+
85+
7586
for attribute in new["attributes"]:
7687
if attribute["name"] == action.attribute_name:
77-
for lenum_value in attribute["type"]["values"]:
78-
if lenum_value["key"] == action.new_value.key:
79-
lenum_value["label"] = action.new_value.label
80-
return new
88+
result = update_attribute_type(attribute["type"])
89+
if result is not None:
90+
return result
8191

8292
raise InternalUpdateError(
8393
"No attribute found with name %r"

0 commit comments

Comments
 (0)