Skip to content

Commit 3f90a1f

Browse files
OMpawar-21claude
andcommitted
test: add integration tests for taxonomy publish/unpublish/localize/unlocalize and terms localize/unlocalize
test_07_taxonomy.py: - TestTaxonomyLocalize: localize → unlocalize against live stack - TestTaxonomyPublish: publish → unpublish (skips gracefully if taxonomy_publish feature not enabled) test_08_terms.py: - TestTermsLocalize: localize → unlocalize against live stack Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 88d5b02 commit 3f90a1f

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

tests/integration/api/test_07_taxonomy.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,54 @@ def test_fetch_nonexistent(self, stack):
3939
h.assert_status(resp, 404, 422)
4040

4141

42+
class TestTaxonomyLocalize:
43+
def test_localize(self, stack, store):
44+
"""Localize a taxonomy into a non-master locale."""
45+
uid = store["taxonomies"]["main"]
46+
locale = store["locales"].get("custom", "fr-fr")
47+
data = {"taxonomy": {"name": f"Taxonomy {locale}"}}
48+
resp = stack.taxonomy(uid).localize(data, locale)
49+
h.assert_status(resp, 200, 201)
50+
h.wait(h.SHORT_DELAY)
51+
52+
def test_unlocalize(self, stack, store):
53+
"""Remove the non-master locale variant."""
54+
uid = store["taxonomies"]["main"]
55+
locale = store["locales"].get("custom", "fr-fr")
56+
stack.client.headers.pop("Content-Type", None)
57+
resp = stack.taxonomy(uid).unlocalize(locale)
58+
h.assert_status(resp, 200, 204)
59+
60+
61+
class TestTaxonomyPublish:
62+
def test_publish(self, stack, store):
63+
"""Publish a taxonomy (requires taxonomy_publish feature flag on the stack)."""
64+
uid = store["taxonomies"]["main"]
65+
env = store["environments"].get("main")
66+
locale = store["locales"].get("custom", "fr-fr")
67+
if not env:
68+
pytest.skip("No environment in store — skipping publish test")
69+
data = {"locales": [locale], "environments": [env], "items": [{"uid": uid}]}
70+
resp = stack.taxonomy().publish(data)
71+
if resp.status_code == 403:
72+
pytest.skip("taxonomy_publish feature not enabled on this stack")
73+
h.assert_status(resp, 200, 201, 202)
74+
h.wait(h.SHORT_DELAY)
75+
76+
def test_unpublish(self, stack, store):
77+
"""Unpublish a taxonomy (requires taxonomy_publish feature flag on the stack)."""
78+
uid = store["taxonomies"]["main"]
79+
env = store["environments"].get("main")
80+
locale = store["locales"].get("custom", "fr-fr")
81+
if not env:
82+
pytest.skip("No environment in store — skipping unpublish test")
83+
data = {"locales": [locale], "environments": [env], "items": [{"uid": uid}]}
84+
resp = stack.taxonomy().unpublish(data)
85+
if resp.status_code == 403:
86+
pytest.skip("taxonomy_publish feature not enabled on this stack")
87+
h.assert_status(resp, 200, 201, 202)
88+
89+
4290
class TestTaxonomyDelete:
4391
def test_delete(self, stack):
4492
uid = h.generate_valid_uid("tax_del")

tests/integration/api/test_08_terms.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,25 @@ def test_fetch_nonexistent(self, stack, taxonomy_uid):
7878
h.assert_status(resp, 404, 422)
7979

8080

81+
class TestTermsLocalize:
82+
def test_localize(self, stack, store, taxonomy_uid):
83+
"""Localize a term into a non-master locale."""
84+
uid = store["terms"]["main"]
85+
locale = store["locales"].get("custom", "fr-fr")
86+
data = {"term": {"name": f"Term {locale}"}}
87+
resp = stack.taxonomy(taxonomy_uid).terms(uid).localize(data, locale)
88+
h.assert_status(resp, 200, 201)
89+
h.wait(h.SHORT_DELAY)
90+
91+
def test_unlocalize(self, stack, store, taxonomy_uid):
92+
"""Remove the non-master locale variant of a term."""
93+
uid = store["terms"]["main"]
94+
locale = store["locales"].get("custom", "fr-fr")
95+
stack.client.headers.pop("Content-Type", None)
96+
resp = stack.taxonomy(taxonomy_uid).terms(uid).unlocalize(locale)
97+
h.assert_status(resp, 200, 204)
98+
99+
81100
class TestTermsDelete:
82101
def test_delete(self, stack, taxonomy_uid):
83102
uid = h.generate_valid_uid("term_del")

0 commit comments

Comments
 (0)