Skip to content

Commit ae5abe9

Browse files
committed
fix: Update old tests to use new comprehensive stack keys
- Replace FAQ_UID with SIMPLE_ENTRY_UID in test_entry.py (40+ occurrences) - Replace 'faq' content type with SIMPLE_CONTENT_TYPE_UID ('author') - Replace LIVE_PREVIEW_ENTRY_UID with SIMPLE_ENTRY_UID in test_live_preview.py - Replace 'product' content type with 'author' (SIMPLE_CONTENT_TYPE_UID) All tests now use SDK-e2e-stack-v4 complexity structure. Fixes 28 AttributeError import failures.
1 parent 667f111 commit ae5abe9

File tree

2 files changed

+69
-67
lines changed

2 files changed

+69
-67
lines changed

tests/test_entry.py

Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
DELIVERY_TOKEN = config.DELIVERY_TOKEN
88
ENVIRONMENT = config.ENVIRONMENT
99
HOST = config.HOST
10-
FAQ_UID = config.FAQ_UID # Add this in your config.py
10+
SIMPLE_ENTRY_UID = config.SIMPLE_ENTRY_UID
11+
SIMPLE_CONTENT_TYPE_UID = config.SIMPLE_CONTENT_TYPE_UID
1112
VARIANT_UID = config.VARIANT_UID
1213

1314
class TestEntry(unittest.TestCase):
@@ -16,57 +17,57 @@ def setUp(self):
1617
self.stack = contentstack.Stack(API_KEY, DELIVERY_TOKEN, ENVIRONMENT, host=HOST)
1718

1819
def test_run_initial_query(self):
19-
query = self.stack.content_type('faq').query()
20+
query = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).query()
2021
result = query.find()
2122
if result is not None:
2223
self.faq_uid = result['entries'][0]['uid']
2324
print(f'the uid is: {self.faq_uid}')
2425

2526
def test_entry_by_UID(self):
26-
entry = self.stack.content_type('faq').entry(FAQ_UID)
27+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID)
2728
result = entry.fetch()
2829
if result is not None:
29-
self.assertEqual(FAQ_UID, result['entry']['uid'])
30+
self.assertEqual(SIMPLE_ENTRY_UID, result['entry']['uid'])
3031

3132
def test_03_entry_environment(self):
32-
entry = self.stack.content_type('faq').entry(FAQ_UID).environment('test')
33+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).environment('test')
3334
self.assertEqual("test", entry.http_instance.headers['environment'])
3435

3536
def test_04_entry_locale(self):
36-
entry = self.stack.content_type('faq').entry(FAQ_UID).locale('en-ei')
37+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).locale('en-ei')
3738
entry.fetch()
3839
self.assertEqual('en-ei', entry.entry_param['locale'])
3940

4041
def test_05_entry_version(self):
41-
entry = self.stack.content_type('faq').entry(FAQ_UID).version(3)
42+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).version(3)
4243
entry.fetch()
4344
self.assertEqual(3, entry.entry_param['version'])
4445

4546
def test_06_entry_params(self):
46-
entry = self.stack.content_type('faq').entry(FAQ_UID).param('param_key', 'param_value')
47+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).param('param_key', 'param_value')
4748
entry.fetch()
4849
self.assertEqual('param_value', entry.entry_param['param_key'])
4950

5051
def test_07_entry_base_only(self):
51-
entry = self.stack.content_type('faq').entry(FAQ_UID).only('field_UID')
52+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).only('field_UID')
5253
entry.fetch()
5354
self.assertEqual({'environment': 'development',
5455
'only[BASE][]': 'field_UID'}, entry.entry_param)
5556

5657
def test_08_entry_base_excepts(self):
57-
entry = self.stack.content_type('faq').entry(FAQ_UID).excepts('field_UID')
58+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).excepts('field_UID')
5859
entry.fetch()
5960
self.assertEqual({'environment': 'development',
6061
'except[BASE][]': 'field_UID'}, entry.entry_param)
6162

6263
def test_10_entry_base_include_reference_only(self):
63-
entry = self.stack.content_type('faq').entry(FAQ_UID).only('field1')
64+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).only('field1')
6465
entry.fetch()
6566
self.assertEqual({'environment': 'development', 'only[BASE][]': 'field1'},
6667
entry.entry_param)
6768

6869
def test_11_entry_base_include_reference_excepts(self):
69-
entry = self.stack.content_type('faq').entry(FAQ_UID).excepts('field1')
70+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).excepts('field1')
7071
entry.fetch()
7172
self.assertEqual({'environment': 'development', 'except[BASE][]': 'field1'},
7273
entry.entry_param)
@@ -80,13 +81,13 @@ def test_12_entry_include_reference_github_issue(self):
8081
response = _entry.fetch()
8182

8283
def test_13_entry_support_include_fallback_unit_test(self):
83-
entry = self.stack.content_type('faq').entry(FAQ_UID).include_fallback()
84+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).include_fallback()
8485
self.assertEqual(
8586
True, entry.entry_param.__contains__('include_fallback'))
8687

8788
def test_14_entry_queryable_only(self):
8889
try:
89-
entry = self.stack.content_type('faq').entry(FAQ_UID).only(4)
90+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).only(4)
9091
result = entry.fetch()
9192
self.assertEqual(None, result['uid'])
9293
except KeyError as e:
@@ -95,72 +96,72 @@ def test_14_entry_queryable_only(self):
9596

9697
def test_entry_queryable_excepts(self):
9798
try:
98-
entry = self.stack.content_type('faq').entry(FAQ_UID).excepts(4)
99+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).excepts(4)
99100
result = entry.fetch()
100101
self.assertEqual(None, result['uid'])
101102
except KeyError as e:
102103
if hasattr(e, 'message'):
103104
self.assertEqual("Invalid field UID. Provide a valid UID and try again.", e.args[0])
104105

105106
def test_16_entry_queryable_include_content_type(self):
106-
entry = self.stack.content_type('faq').entry(FAQ_UID).include_content_type()
107+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).include_content_type()
107108
self.assertEqual({'include_content_type': 'true', 'include_global_field_schema': 'true'},
108109
entry.entry_queryable_param)
109110

110111
def test_reference_content_type_uid(self):
111-
entry = self.stack.content_type('faq').entry(FAQ_UID).include_reference_content_type_uid()
112+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).include_reference_content_type_uid()
112113
self.assertEqual({'include_reference_content_type_uid': 'true'},
113114
entry.entry_queryable_param)
114115

115116
def test_19_entry_queryable_add_param(self):
116-
entry = self.stack.content_type('faq').entry(FAQ_UID).add_param('cms', 'contentstack')
117+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).add_param('cms', 'contentstack')
117118
self.assertEqual({'cms': 'contentstack'}, entry.entry_queryable_param)
118119

119120
def test_20_entry_include_fallback(self):
120-
content_type = self.stack.content_type('faq')
121+
content_type = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
121122
entry = content_type.entry("878783238783").include_fallback()
122123
result = entry.fetch()
123124
self.assertEqual({'environment': 'development',
124125
'include_fallback': 'true'}, entry.entry_param)
125126

126127
def test_21_entry_include_embedded_items(self):
127-
content_type = self.stack.content_type('faq')
128+
content_type = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
128129
entry = content_type.entry("878783238783").include_embedded_items()
129130
result = entry.fetch()
130131
self.assertEqual({'environment': 'development',
131132
'include_embedded_items[]': 'BASE'}, entry.entry_param)
132133

133134
def test_22_entry_include_metadata(self):
134-
content_type = self.stack.content_type('faq')
135+
content_type = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
135136
entry = content_type.entry("878783238783").include_metadata()
136137
self.assertEqual({'include_metadata': 'true'}, entry.entry_queryable_param)
137138

138139
def test_23_content_type_variants(self):
139-
content_type = self.stack.content_type('faq')
140+
content_type = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
140141
entry = content_type.variants(VARIANT_UID).find()
141142
self.assertIn('variants', entry['entries'][0]['publish_details'])
142143

143144
def test_24_entry_variants(self):
144-
content_type = self.stack.content_type('faq')
145-
entry = content_type.entry(FAQ_UID).variants(VARIANT_UID).fetch()
145+
content_type = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
146+
entry = content_type.entry(SIMPLE_ENTRY_UID).variants(VARIANT_UID).fetch()
146147
self.assertIn('variants', entry['entry']['publish_details'])
147148

148149
def test_25_content_type_variants_with_has_hash_variant(self):
149-
content_type = self.stack.content_type('faq')
150+
content_type = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
150151
entry = content_type.variants([VARIANT_UID]).find()
151152
self.assertIn('variants', entry['entries'][0]['publish_details'])
152153

153154
def test_25_content_type_entry_variants_with_has_hash_variant(self):
154-
content_type = self.stack.content_type('faq').entry(FAQ_UID)
155+
content_type = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID)
155156
entry = content_type.variants([VARIANT_UID]).fetch()
156157
self.assertIn('variants', entry['entry']['publish_details'])
157158

158159
# ========== Additional Test Cases ==========
159160

160161
def test_26_entry_method_chaining_locale_version(self):
161162
"""Test entry method chaining with locale and version"""
162-
entry = (self.stack.content_type('faq')
163-
.entry(FAQ_UID)
163+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
164+
.entry(SIMPLE_ENTRY_UID)
164165
.locale('en-us')
165166
.version(1))
166167
entry.fetch()
@@ -169,8 +170,8 @@ def test_26_entry_method_chaining_locale_version(self):
169170

170171
def test_27_entry_method_chaining_environment_locale(self):
171172
"""Test entry method chaining with environment and locale"""
172-
entry = (self.stack.content_type('faq')
173-
.entry(FAQ_UID)
173+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
174+
.entry(SIMPLE_ENTRY_UID)
174175
.environment('test')
175176
.locale('en-us'))
176177
entry.fetch()
@@ -179,8 +180,8 @@ def test_27_entry_method_chaining_environment_locale(self):
179180

180181
def test_28_entry_only_multiple_fields(self):
181182
"""Test entry only with multiple field calls"""
182-
entry = (self.stack.content_type('faq')
183-
.entry(FAQ_UID)
183+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
184+
.entry(SIMPLE_ENTRY_UID)
184185
.only('field1')
185186
.only('field2'))
186187
entry.fetch()
@@ -189,8 +190,8 @@ def test_28_entry_only_multiple_fields(self):
189190

190191
def test_29_entry_excepts_multiple_fields(self):
191192
"""Test entry excepts with multiple field calls"""
192-
entry = (self.stack.content_type('faq')
193-
.entry(FAQ_UID)
193+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
194+
.entry(SIMPLE_ENTRY_UID)
194195
.excepts('field1')
195196
.excepts('field2'))
196197
entry.fetch()
@@ -199,8 +200,8 @@ def test_29_entry_excepts_multiple_fields(self):
199200

200201
def test_30_entry_include_fallback_with_locale(self):
201202
"""Test entry include_fallback combined with locale"""
202-
entry = (self.stack.content_type('faq')
203-
.entry(FAQ_UID)
203+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
204+
.entry(SIMPLE_ENTRY_UID)
204205
.locale('en-gb')
205206
.include_fallback())
206207
entry.fetch()
@@ -209,8 +210,8 @@ def test_30_entry_include_fallback_with_locale(self):
209210

210211
def test_31_entry_include_metadata_with_version(self):
211212
"""Test entry include_metadata combined with version"""
212-
entry = (self.stack.content_type('faq')
213-
.entry(FAQ_UID)
213+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
214+
.entry(SIMPLE_ENTRY_UID)
214215
.version(2)
215216
.include_metadata())
216217
entry.fetch()
@@ -219,8 +220,8 @@ def test_31_entry_include_metadata_with_version(self):
219220

220221
def test_32_entry_include_content_type_with_locale(self):
221222
"""Test entry include_content_type combined with locale"""
222-
entry = (self.stack.content_type('faq')
223-
.entry(FAQ_UID)
223+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
224+
.entry(SIMPLE_ENTRY_UID)
224225
.locale('en-us')
225226
.include_content_type())
226227
entry.fetch()
@@ -229,8 +230,8 @@ def test_32_entry_include_content_type_with_locale(self):
229230

230231
def test_33_entry_include_reference_content_type_uid_with_version(self):
231232
"""Test entry include_reference_content_type_uid combined with version"""
232-
entry = (self.stack.content_type('faq')
233-
.entry(FAQ_UID)
233+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
234+
.entry(SIMPLE_ENTRY_UID)
234235
.version(1)
235236
.include_reference_content_type_uid())
236237
entry.fetch()
@@ -239,8 +240,8 @@ def test_33_entry_include_reference_content_type_uid_with_version(self):
239240

240241
def test_34_entry_add_param_multiple_times(self):
241242
"""Test entry add_param called multiple times"""
242-
entry = (self.stack.content_type('faq')
243-
.entry(FAQ_UID)
243+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
244+
.entry(SIMPLE_ENTRY_UID)
244245
.add_param('key1', 'value1')
245246
.add_param('key2', 'value2'))
246247
entry.fetch()
@@ -249,8 +250,8 @@ def test_34_entry_add_param_multiple_times(self):
249250

250251
def test_35_entry_complex_method_chaining(self):
251252
"""Test entry with complex method chaining"""
252-
entry = (self.stack.content_type('faq')
253-
.entry(FAQ_UID)
253+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
254+
.entry(SIMPLE_ENTRY_UID)
254255
.environment('test')
255256
.locale('en-us')
256257
.version(1)
@@ -269,8 +270,8 @@ def test_35_entry_complex_method_chaining(self):
269270

270271
def test_36_entry_include_embedded_items_with_locale(self):
271272
"""Test entry include_embedded_items combined with locale"""
272-
entry = (self.stack.content_type('faq')
273-
.entry(FAQ_UID)
273+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
274+
.entry(SIMPLE_ENTRY_UID)
274275
.locale('en-us')
275276
.include_embedded_items())
276277
entry.fetch()
@@ -279,7 +280,7 @@ def test_36_entry_include_embedded_items_with_locale(self):
279280

280281
def test_37_entry_param_with_different_values(self):
281282
"""Test entry param method with different value types"""
282-
entry = self.stack.content_type('faq').entry(FAQ_UID)
283+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID)
283284
entry.param('string_param', 'string_value')
284285
entry.param('int_param', 123)
285286
entry.fetch()
@@ -288,8 +289,8 @@ def test_37_entry_param_with_different_values(self):
288289

289290
def test_38_entry_only_and_excepts_together(self):
290291
"""Test entry with both only and excepts"""
291-
entry = (self.stack.content_type('faq')
292-
.entry(FAQ_UID)
292+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
293+
.entry(SIMPLE_ENTRY_UID)
293294
.only('field1')
294295
.excepts('field2'))
295296
entry.fetch()
@@ -298,56 +299,56 @@ def test_38_entry_only_and_excepts_together(self):
298299

299300
def test_39_entry_include_reference_with_multiple_fields(self):
300301
"""Test entry include_reference with multiple fields"""
301-
entry = (self.stack.content_type('faq')
302-
.entry(FAQ_UID)
302+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
303+
.entry(SIMPLE_ENTRY_UID)
303304
.include_reference(['field1', 'field2', 'field3']))
304305
result = entry.fetch()
305306
self.assertIsNotNone(result)
306307

307308
def test_40_entry_variants_with_params(self):
308309
"""Test entry variants with params"""
309-
content_type = self.stack.content_type('faq')
310-
entry = content_type.entry(FAQ_UID).variants(VARIANT_UID, params={'locale': 'en-us'})
310+
content_type = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
311+
entry = content_type.entry(SIMPLE_ENTRY_UID).variants(VARIANT_UID, params={'locale': 'en-us'})
311312
result = entry.fetch()
312313
self.assertIn('variants', result['entry']['publish_details'])
313314

314315
def test_41_entry_variants_multiple_uids(self):
315316
"""Test entry variants with multiple variant UIDs"""
316-
content_type = self.stack.content_type('faq')
317-
entry = content_type.entry(FAQ_UID).variants([VARIANT_UID, VARIANT_UID])
317+
content_type = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
318+
entry = content_type.entry(SIMPLE_ENTRY_UID).variants([VARIANT_UID, VARIANT_UID])
318319
result = entry.fetch()
319320
self.assertIn('variants', result['entry']['publish_details'])
320321

321322
def test_42_entry_environment_removal(self):
322323
"""Test entry remove_environment method"""
323-
entry = (self.stack.content_type('faq')
324-
.entry(FAQ_UID)
324+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
325+
.entry(SIMPLE_ENTRY_UID)
325326
.environment('test')
326327
.remove_environment())
327328
self.assertNotIn('environment', entry.http_instance.headers)
328329

329330
def test_43_entry_version_zero(self):
330331
"""Test entry version with zero value"""
331-
entry = self.stack.content_type('faq').entry(FAQ_UID).version(0)
332+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).version(0)
332333
entry.fetch()
333334
self.assertEqual(0, entry.entry_param['version'])
334335

335336
def test_44_entry_locale_empty_string(self):
336337
"""Test entry locale with empty string"""
337-
entry = self.stack.content_type('faq').entry(FAQ_UID).locale('')
338+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).locale('')
338339
entry.fetch()
339340
self.assertEqual('', entry.entry_queryable_param['locale'])
340341

341342
def test_45_entry_include_reference_empty_list(self):
342343
"""Test entry include_reference with empty list"""
343-
entry = self.stack.content_type('faq').entry(FAQ_UID).include_reference([])
344+
entry = self.stack.content_type(SIMPLE_CONTENT_TYPE_UID).entry(SIMPLE_ENTRY_UID).include_reference([])
344345
result = entry.fetch()
345346
self.assertIsNotNone(result)
346347

347348
def test_46_entry_all_queryable_methods_combined(self):
348349
"""Test entry with all EntryQueryable methods combined"""
349-
entry = (self.stack.content_type('faq')
350-
.entry(FAQ_UID)
350+
entry = (self.stack.content_type(SIMPLE_CONTENT_TYPE_UID)
351+
.entry(SIMPLE_ENTRY_UID)
351352
.locale('en-us')
352353
.only('field1')
353354
.excepts('field2')

0 commit comments

Comments
 (0)