Skip to content

Commit fbee506

Browse files
OMpawar-21claude
andcommitted
test: add integration and unit tests for ContentType.variants() branch support
- Added integration tests (41e, 41f) in test_entry.py for branch as keyword arg and branch combined with query params on content_type.variants().find() - Moved fetch-raises-without-entry-uid assertion to test_variants.py as a unit test (mocked, no network) where it logically belongs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1cc2bb3 commit fbee506

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

tests/test_entry.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,20 @@ def test_41d_content_type_variants_multiple_uids_find_with_branch(self):
347347
result = content_type.variants([VARIANT_UID], BRANCH).find()
348348
self.assertIn('variants', result['entries'][0]['publish_details'])
349349

350+
@unittest.skipIf(BRANCH is None, "config.BRANCH is required for branch variant tests")
351+
def test_41e_content_type_variants_branch_as_keyword_arg(self):
352+
"""Test content_type.variants() with branch passed as keyword argument"""
353+
content_type = self.stack.content_type('faq')
354+
result = content_type.variants(VARIANT_UID, branch=BRANCH).find()
355+
self.assertIn('variants', result['entries'][0]['publish_details'])
356+
357+
@unittest.skipIf(BRANCH is None, "config.BRANCH is required for branch variant tests")
358+
def test_41f_content_type_variants_branch_with_params(self):
359+
"""Test content_type.variants() with branch and extra query params"""
360+
content_type = self.stack.content_type('faq')
361+
result = content_type.variants(VARIANT_UID, branch=BRANCH, params={'locale': 'en-us'}).find()
362+
self.assertIn('variants', result['entries'][0]['publish_details'])
363+
350364
def test_42_entry_environment_removal(self):
351365
"""Test entry remove_environment method"""
352366
entry = (self.stack.content_type('faq')

tests/test_variants.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,12 @@ def test_variants_backward_compatible_params_kwarg(self, mock_http_instance):
188188
result = entry.variants("variant_uid", params={"locale": "en-us"})
189189
assert result.branch is None
190190
assert result.entry_param == {"locale": "en-us"}
191+
192+
def test_content_type_variants_fetch_raises_without_entry_uid(self, mock_http_instance):
193+
from contentstack.contenttype import ContentType
194+
import pytest
195+
196+
content_type = ContentType(mock_http_instance, "faq")
197+
variants = content_type.variants("variant_uid")
198+
with pytest.raises(ValueError):
199+
variants.fetch()

0 commit comments

Comments
 (0)