33import config
44import contentstack
55
6- _UID = 'blt53ca1231625bdde4'
76API_KEY = config .APIKEY
87DELIVERY_TOKEN = config .DELIVERYTOKEN
98ENVIRONMENT = config .ENVIRONMENT
109HOST = config .HOST
10+ FAQ_UID = config .FAQ_UID # Add this in your config.py
1111
1212
1313class TestEntry (unittest .TestCase ):
@@ -19,69 +19,54 @@ def test_run_initial_query(self):
1919 query = self .stack .content_type ('faq' ).query ()
2020 result = query .find ()
2121 if result is not None :
22- self ._UID = result ['entries' ][0 ]['uid' ]
23- print (f'the uid is: { _UID } ' )
22+ self .faq_uid = result ['entries' ][0 ]['uid' ]
23+ print (f'the uid is: { self . faq_uid } ' )
2424
2525 def test_entry_by_UID (self ):
26- global _UID
27- entry = self .stack .content_type ('faq' ).entry (_UID )
26+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID )
2827 result = entry .fetch ()
2928 if result is not None :
30- _UID = result ['entry' ]['uid' ]
31- self .assertEqual (_UID , result ['entry' ]['uid' ])
29+ self .assertEqual (FAQ_UID , result ['entry' ]['uid' ])
3230
3331 def test_03_entry_environment (self ):
34- global _UID
35- entry = self .stack .content_type ('faq' ).entry (
36- _UID ).environment ('test' )
32+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).environment ('test' )
3733 self .assertEqual ("test" , entry .http_instance .headers ['environment' ])
3834
3935 def test_04_entry_locale (self ):
40- global _UID
41- entry = self .stack .content_type ('faq' ).entry (_UID ).locale ('en-ei' )
36+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).locale ('en-ei' )
4237 entry .fetch ()
4338 self .assertEqual ('en-ei' , entry .entry_param ['locale' ])
4439
4540 def test_05_entry_version (self ):
46- global _UID
47- entry = self .stack .content_type ('faq' ).entry (_UID ).version (3 )
41+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).version (3 )
4842 entry .fetch ()
4943 self .assertEqual (3 , entry .entry_param ['version' ])
5044
5145 def test_06_entry_params (self ):
52- global _UID
53- entry = self .stack .content_type ('faq' ).entry (
54- _UID ).param ('param_key' , 'param_value' )
46+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).param ('param_key' , 'param_value' )
5547 entry .fetch ()
5648 self .assertEqual ('param_value' , entry .entry_param ['param_key' ])
5749
5850 def test_07_entry_base_only (self ):
59- global _UID
60- entry = self .stack .content_type (
61- 'faq' ).entry (_UID ).only ('field_UID' )
51+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).only ('field_UID' )
6252 entry .fetch ()
6353 self .assertEqual ({'environment' : 'development' ,
6454 'only[BASE][]' : 'field_UID' }, entry .entry_param )
6555
6656 def test_08_entry_base_excepts (self ):
67- global _UID
68- entry = self .stack .content_type ('faq' ).entry (
69- _UID ).excepts ('field_UID' )
57+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).excepts ('field_UID' )
7058 entry .fetch ()
7159 self .assertEqual ({'environment' : 'development' ,
7260 'except[BASE][]' : 'field_UID' }, entry .entry_param )
7361
7462 def test_10_entry_base_include_reference_only (self ):
75- global _UID
76- entry = self .stack .content_type ('faq' ).entry (_UID ).only ('field1' )
63+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).only ('field1' )
7764 entry .fetch ()
7865 self .assertEqual ({'environment' : 'development' , 'only[BASE][]' : 'field1' },
7966 entry .entry_param )
8067
8168 def test_11_entry_base_include_reference_excepts (self ):
82- global _UID
83- entry = self .stack .content_type (
84- 'faq' ).entry (_UID ).excepts ('field1' )
69+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).excepts ('field1' )
8570 entry .fetch ()
8671 self .assertEqual ({'environment' : 'development' , 'except[BASE][]' : 'field1' },
8772 entry .entry_param )
@@ -95,15 +80,13 @@ def test_12_entry_include_reference_github_issue(self):
9580 response = _entry .fetch ()
9681
9782 def test_13_entry_support_include_fallback_unit_test (self ):
98- global _UID
99- entry = self .stack .content_type ('faq' ).entry (
100- _UID ).include_fallback ()
83+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).include_fallback ()
10184 self .assertEqual (
10285 True , entry .entry_param .__contains__ ('include_fallback' ))
10386
10487 def test_14_entry_queryable_only (self ):
10588 try :
106- entry = self .stack .content_type ('faq' ).entry (_UID ).only (4 )
89+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).only (4 )
10790 result = entry .fetch ()
10891 self .assertEqual (None , result ['uid' ])
10992 except KeyError as e :
@@ -112,28 +95,25 @@ def test_14_entry_queryable_only(self):
11295
11396 def test_entry_queryable_excepts (self ):
11497 try :
115- entry = self .stack .content_type ('faq' ).entry (_UID ).excepts (4 )
98+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).excepts (4 )
11699 result = entry .fetch ()
117100 self .assertEqual (None , result ['uid' ])
118101 except KeyError as e :
119102 if hasattr (e , 'message' ):
120103 self .assertEqual ("Invalid field_UID provided" , e .args [0 ])
121104
122105 def test_16_entry_queryable_include_content_type (self ):
123- entry = self .stack .content_type ('faq' ).entry (
124- _UID ).include_content_type ()
106+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).include_content_type ()
125107 self .assertEqual ({'include_content_type' : 'true' , 'include_global_field_schema' : 'true' },
126108 entry .entry_queryable_param )
127109
128110 def test_reference_content_type_uid (self ):
129- entry = self .stack .content_type ('faq' ).entry (
130- _UID ).include_reference_content_type_uid ()
111+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).include_reference_content_type_uid ()
131112 self .assertEqual ({'include_reference_content_type_uid' : 'true' },
132113 entry .entry_queryable_param )
133114
134115 def test_19_entry_queryable_add_param (self ):
135- entry = self .stack .content_type ('faq' ).entry (
136- _UID ).add_param ('cms' , 'contentstack' )
116+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).add_param ('cms' , 'contentstack' )
137117 self .assertEqual ({'cms' : 'contentstack' }, entry .entry_queryable_param )
138118
139119 def test_20_entry_include_fallback (self ):
0 commit comments