3
3
import config
4
4
import contentstack
5
5
6
- _UID = 'blt53ca1231625bdde4'
7
6
API_KEY = config .APIKEY
8
7
DELIVERY_TOKEN = config .DELIVERYTOKEN
9
8
ENVIRONMENT = config .ENVIRONMENT
10
9
HOST = config .HOST
10
+ FAQ_UID = config .FAQ_UID # Add this in your config.py
11
11
12
12
13
13
class TestEntry (unittest .TestCase ):
@@ -19,69 +19,54 @@ def test_run_initial_query(self):
19
19
query = self .stack .content_type ('faq' ).query ()
20
20
result = query .find ()
21
21
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 } ' )
24
24
25
25
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 )
28
27
result = entry .fetch ()
29
28
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' ])
32
30
33
31
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' )
37
33
self .assertEqual ("test" , entry .http_instance .headers ['environment' ])
38
34
39
35
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' )
42
37
entry .fetch ()
43
38
self .assertEqual ('en-ei' , entry .entry_param ['locale' ])
44
39
45
40
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 )
48
42
entry .fetch ()
49
43
self .assertEqual (3 , entry .entry_param ['version' ])
50
44
51
45
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' )
55
47
entry .fetch ()
56
48
self .assertEqual ('param_value' , entry .entry_param ['param_key' ])
57
49
58
50
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' )
62
52
entry .fetch ()
63
53
self .assertEqual ({'environment' : 'development' ,
64
54
'only[BASE][]' : 'field_UID' }, entry .entry_param )
65
55
66
56
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' )
70
58
entry .fetch ()
71
59
self .assertEqual ({'environment' : 'development' ,
72
60
'except[BASE][]' : 'field_UID' }, entry .entry_param )
73
61
74
62
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' )
77
64
entry .fetch ()
78
65
self .assertEqual ({'environment' : 'development' , 'only[BASE][]' : 'field1' },
79
66
entry .entry_param )
80
67
81
68
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' )
85
70
entry .fetch ()
86
71
self .assertEqual ({'environment' : 'development' , 'except[BASE][]' : 'field1' },
87
72
entry .entry_param )
@@ -95,15 +80,13 @@ def test_12_entry_include_reference_github_issue(self):
95
80
response = _entry .fetch ()
96
81
97
82
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 ()
101
84
self .assertEqual (
102
85
True , entry .entry_param .__contains__ ('include_fallback' ))
103
86
104
87
def test_14_entry_queryable_only (self ):
105
88
try :
106
- entry = self .stack .content_type ('faq' ).entry (_UID ).only (4 )
89
+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).only (4 )
107
90
result = entry .fetch ()
108
91
self .assertEqual (None , result ['uid' ])
109
92
except KeyError as e :
@@ -112,28 +95,25 @@ def test_14_entry_queryable_only(self):
112
95
113
96
def test_entry_queryable_excepts (self ):
114
97
try :
115
- entry = self .stack .content_type ('faq' ).entry (_UID ).excepts (4 )
98
+ entry = self .stack .content_type ('faq' ).entry (FAQ_UID ).excepts (4 )
116
99
result = entry .fetch ()
117
100
self .assertEqual (None , result ['uid' ])
118
101
except KeyError as e :
119
102
if hasattr (e , 'message' ):
120
103
self .assertEqual ("Invalid field_UID provided" , e .args [0 ])
121
104
122
105
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 ()
125
107
self .assertEqual ({'include_content_type' : 'true' , 'include_global_field_schema' : 'true' },
126
108
entry .entry_queryable_param )
127
109
128
110
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 ()
131
112
self .assertEqual ({'include_reference_content_type_uid' : 'true' },
132
113
entry .entry_queryable_param )
133
114
134
115
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' )
137
117
self .assertEqual ({'cms' : 'contentstack' }, entry .entry_queryable_param )
138
118
139
119
def test_20_entry_include_fallback (self ):
0 commit comments