Skip to content

Commit c874526

Browse files
Merge pull request #125 from labd/fix/categories-fix
Fix/categories fix
2 parents a5e7150 + ed53434 commit c874526

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/commercetools/testing/categories.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ def _create_from_draft(
3232
created_at=datetime.datetime.now(datetime.timezone.utc),
3333
last_modified_at=datetime.datetime.now(datetime.timezone.utc),
3434
ancestors=[],
35-
order_hint="",
35+
order_hint=draft.order_hint,
3636
custom=utils.create_from_draft(draft.custom),
37+
parent=draft.parent,
3738
)
3839

3940

@@ -50,6 +51,12 @@ def urls(self):
5051
("^$", "POST", self.create),
5152
("^key=(?P<key>[^/]+)$", "GET", self.get_by_key),
5253
("^key=(?P<key>[^/]+)$", "POST", self.update_by_key),
54+
("^key=(?P<key>[^/]+)$", "DELETE", self.delete_by_key),
5355
("^(?P<id>[^/]+)$", "GET", self.get_by_id),
5456
("^(?P<id>[^/]+)$", "POST", self.update_by_id),
57+
("^(?P<id>[^/]+)$", "DELETE", self.delete_by_id),
5558
]
59+
60+
_actions = {
61+
"setDescription": utils.update_attribute("description", "description"),
62+
}

tests/platform/test_service_categories.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,40 @@ def test_category_update(old_client):
7777
It doesn't test the actual update itself.
7878
TODO: See if this is worth testing since we're using a mocking backend
7979
"""
80+
parent_category = old_client.categories.create(
81+
models.CategoryDraft(
82+
key="parent-test-category",
83+
slug=models.LocalizedString(nl="nl-slug-parent"),
84+
name=models.LocalizedString(nl="parent-category"),
85+
)
86+
)
87+
8088
category = old_client.categories.create(
8189
models.CategoryDraft(
8290
key="test-category",
8391
slug=models.LocalizedString(nl="nl-slug"),
8492
name=models.LocalizedString(nl="category"),
93+
parent=models.CategoryResourceIdentifier(id=parent_category.id),
94+
order_hint="0.00001",
95+
description=models.LocalizedString(nl="description-nl"),
8596
)
8697
)
8798
assert category.key == "test-category"
99+
assert category.order_hint == "0.00001"
100+
assert getattr(category.parent, "id") == parent_category.id
88101

89102
category = old_client.categories.update_by_id(
90103
id=category.id,
91104
version=category.version,
92105
actions=[
93-
models.CategoryChangeSlugAction(slug=models.LocalizedString(nl="nl-slug2"))
106+
models.CategoryChangeSlugAction(slug=models.LocalizedString(nl="nl-slug2")),
107+
models.CategorySetDescriptionAction(
108+
description=models.LocalizedString(nl="updated-description-nl")
109+
),
94110
],
95111
)
96112
assert category.key == "test-category"
113+
assert category.description == models.LocalizedString(nl="updated-description-nl")
97114

98115
category = old_client.categories.update_by_key(
99116
key="test-category",

0 commit comments

Comments
 (0)