@@ -32,8 +32,10 @@ def test_when_name_is_invalid__validation_error_is_raised(name):
3232 ** {
3333 "name" : name ,
3434 "language" : "en" ,
35- "category" : "ACCOUNT_UPDATE" ,
36- "structure" : {"body" : "example {{1}} body" },
35+ "category" : "OTP" ,
36+ "structure" : {
37+ "body" : {"text" : "body {{1}} content" , "examples" : ["example" ]}
38+ },
3739 }
3840 )
3941
@@ -45,8 +47,10 @@ def test_when_language_is_invalid__validation_error_is_raised(language):
4547 ** {
4648 "name" : "examplename" ,
4749 "language" : language ,
48- "category" : "ACCOUNT_UPDATE" ,
49- "structure" : {"body" : "example {{1}} body" },
50+ "category" : "OTP" ,
51+ "structure" : {
52+ "body" : {"text" : "body {{1}} content" , "examples" : ["example" ]}
53+ },
5054 }
5155 )
5256
@@ -59,7 +63,9 @@ def test_when_category_is_invalid__validation_error_is_raised(category):
5963 "name" : "examplename" ,
6064 "language" : "en" ,
6165 "category" : category ,
62- "structure" : {"body" : "example {{1}} body" },
66+ "structure" : {
67+ "body" : {"text" : "body {{1}} content" , "examples" : ["example" ]}
68+ },
6369 }
6470 )
6571
@@ -83,7 +89,7 @@ def test_when_structure_is_invalid__validation_error_is_raised(structure):
8389 ** {
8490 "name" : "examplename" ,
8591 "language" : "en" ,
86- "category" : "ACCOUNT_UPDATE " ,
92+ "category" : "OTP " ,
8793 "structure" : structure ,
8894 }
8995 )
@@ -96,10 +102,10 @@ def test_when_header_is_invalid__validation_error_is_raised(header):
96102 ** {
97103 "name" : "examplename" ,
98104 "language" : "en" ,
99- "category" : "ACCOUNT_UPDATE " ,
105+ "category" : "OTP " ,
100106 "structure" : {
101107 "header" : header ,
102- "body" : "example {{1}} body" ,
108+ "body" : { "text" : "body {{1}} content" , "examples" : [ "example" ]} ,
103109 },
104110 }
105111 )
@@ -112,7 +118,7 @@ def test_when_body_is_invalid__validation_error_is_raised(body):
112118 ** {
113119 "name" : "examplename" ,
114120 "language" : "en" ,
115- "category" : "ACCOUNT_UPDATE " ,
121+ "category" : "OTP " ,
116122 "structure" : {
117123 "header" : {"format" : "TEXT" , "text" : "Text example" },
118124 "body" : body ,
@@ -121,23 +127,58 @@ def test_when_body_is_invalid__validation_error_is_raised(body):
121127 )
122128
123129
124- @pytest .mark .parametrize ("footer" , [{}, get_random_string (61 )])
130+ @pytest .mark .parametrize ("body_text" , [None , {}])
131+ def test_when_body_text_is_invalid__validation_error_is_raised (body_text ):
132+ with pytest .raises (ValidationError ):
133+ CreateTemplateBodyFactory .build (
134+ ** {
135+ "name" : "examplename" ,
136+ "language" : "en" ,
137+ "category" : "OTP" ,
138+ "structure" : {
139+ "header" : {"format" : "TEXT" , "text" : "Text example" },
140+ "body" : {
141+ "text" : body_text ,
142+ },
143+ },
144+ }
145+ )
146+
147+
148+ @pytest .mark .parametrize ("footer" , [{}])
125149def test_when_footer_is_invalid__validation_error_is_raised (footer ):
126150 with pytest .raises (ValidationError ):
127151 CreateTemplateBodyFactory .build (
128152 ** {
129153 "name" : "examplename" ,
130154 "language" : "en" ,
131- "category" : "ACCOUNT_UPDATE " ,
155+ "category" : "OTP " ,
132156 "structure" : {
133157 "header" : {"format" : "TEXT" , "text" : "Text example" },
134- "body" : "text" ,
158+ "body" : { "text" : "body {{1}} content" , "examples" : [ "example" ]} ,
135159 "footer" : footer ,
136160 },
137161 }
138162 )
139163
140164
165+ @pytest .mark .parametrize ("footer_text" , [{}, get_random_string (61 )])
166+ def test_when_footer_text_is_invalid__validation_error_is_raised (footer_text ):
167+ with pytest .raises (ValidationError ):
168+ CreateTemplateBodyFactory .build (
169+ ** {
170+ "name" : "examplename" ,
171+ "language" : "en" ,
172+ "category" : "OTP" ,
173+ "structure" : {
174+ "header" : {"format" : "TEXT" , "text" : "Text example" },
175+ "body" : {"text" : "body {{1}} content" , "examples" : ["example" ]},
176+ "footer" : {"text" : footer_text },
177+ },
178+ }
179+ )
180+
181+
141182@pytest .mark .parametrize (
142183 "buttons" ,
143184 [
@@ -162,8 +203,11 @@ def test_when_buttons_is_invalid__validation_error_is_raised(buttons):
162203 ** {
163204 "name" : "examplename" ,
164205 "language" : "en" ,
165- "category" : "ACCOUNT_UPDATE" ,
166- "structure" : {"body" : "text" , "buttons" : buttons },
206+ "category" : "OTP" ,
207+ "structure" : {
208+ "body" : {"text" : "body {{1}} content" , "examples" : ["example" ]},
209+ "buttons" : buttons ,
210+ },
167211 }
168212 )
169213
@@ -175,8 +219,11 @@ def test_when_button_type_is_invalid__validation_error_is_raised(button_type):
175219 ** {
176220 "name" : "examplename" ,
177221 "language" : "en" ,
178- "category" : "ACCOUNT_UPDATE" ,
179- "structure" : {"body" : "text" , "buttons" : [{"type" : button_type }]},
222+ "category" : "OTP" ,
223+ "structure" : {
224+ "body" : {"text" : "body {{1}} content" , "examples" : ["example" ]},
225+ "buttons" : [{"type" : button_type }],
226+ },
180227 }
181228 )
182229
@@ -188,10 +235,10 @@ def test_when_quick_reply_button_text_is_invalid__validation_error_is_raised(tex
188235 ** {
189236 "name" : "examplename" ,
190237 "language" : "en" ,
191- "category" : "ACCOUNT_UPDATE " ,
238+ "category" : "OTP " ,
192239 "structure" : {
193240 "header" : {"format" : "TEXT" , "text" : "Text example" },
194- "body" : "example {{1}} body" ,
241+ "body" : { "text" : "body {{1}} content" , "examples" : [ "example" ]} ,
195242 "buttons" : [{"type" : "QUICK_REPLY" , "text" : text }],
196243 },
197244 }
@@ -205,10 +252,10 @@ def test_when_phone_number_button_text_is_invalid__validation_error_is_raised(te
205252 ** {
206253 "name" : "examplename" ,
207254 "language" : "en" ,
208- "category" : "ACCOUNT_UPDATE " ,
255+ "category" : "OTP " ,
209256 "structure" : {
210257 "header" : {"format" : "TEXT" , "text" : "Text example" },
211- "body" : "example {{1}} body" ,
258+ "body" : { "text" : "body {{1}} content" , "examples" : [ "example" ]} ,
212259 "buttons" : [
213260 {"type" : "PHONE_NUMBER" , "text" : text , "phoneNumber" : "324561" }
214261 ],
@@ -224,10 +271,10 @@ def test_when_phone_number_button_number_is_invalid__validation_error_is_raised(
224271 ** {
225272 "name" : "examplename" ,
226273 "language" : "en" ,
227- "category" : "ACCOUNT_UPDATE " ,
274+ "category" : "OTP " ,
228275 "structure" : {
229276 "header" : {"format" : "TEXT" , "text" : "Text example" },
230- "body" : "example {{1}} body" ,
277+ "body" : { "text" : "body {{1}} content" , "examples" : [ "example" ]} ,
231278 "buttons" : [
232279 {"type" : "PHONE_NUMBER" , "text" : "test" , "phoneNumber" : number }
233280 ],
@@ -243,10 +290,10 @@ def test_when_url_button_text_is_invalid__validation_error_is_raised(text):
243290 ** {
244291 "name" : "examplename" ,
245292 "language" : "en" ,
246- "category" : "ACCOUNT_UPDATE " ,
293+ "category" : "OTP " ,
247294 "structure" : {
248295 "header" : {"format" : "TEXT" , "text" : "Text example" },
249- "body" : "example {{1}} body" ,
296+ "body" : { "text" : "body {{1}} content" , "examples" : [ "example" ]} ,
250297 "buttons" : [
251298 {"type" : "URL" , "text" : text , "url" : "https://url.com" }
252299 ],
@@ -271,10 +318,10 @@ def test_when_url_button_url_is_invalid__validation_error_is_raised(url):
271318 ** {
272319 "name" : "examplename" ,
273320 "language" : "en" ,
274- "category" : "ACCOUNT_UPDATE " ,
321+ "category" : "OTP " ,
275322 "structure" : {
276323 "header" : {"format" : "TEXT" , "text" : "Text example" },
277- "body" : "example {{1}} body" ,
324+ "body" : { "text" : "body {{1}} content" , "examples" : [ "example" ]} ,
278325 "buttons" : [{"type" : "URL" , "text" : "Text example" , "url" : url }],
279326 },
280327 }
@@ -287,11 +334,11 @@ def test_when_input_data_is_valid__validation_error_is_not_raised():
287334 ** {
288335 "name" : "exampl_ename" ,
289336 "language" : "en" ,
290- "category" : "ACCOUNT_UPDATE " ,
337+ "category" : "OTP " ,
291338 "structure" : {
292339 "header" : {"format" : "TEXT" , "text" : "Text example" },
293- "body" : "example {{1}} body" ,
294- "footer" : "some footer" ,
340+ "body" : { "text" : "body {{1}} content" , "examples" : [ "example" ]} ,
341+ "footer" : { "text" : " footer content" } ,
295342 "buttons" : [
296343 {"type" : "URL" , "text" : "url" , "url" : "http://url.com" },
297344 {
0 commit comments