@@ -139,6 +139,14 @@ def test_edit_invalid_short_description(self):
139
139
'malformed_url' ,
140
140
{'image_url' : 'notalink' },
141
141
),
142
+ (
143
+ 'empty_url' ,
144
+ {'image_url' : '' },
145
+ ),
146
+ (
147
+ 'invalid_url_with_spaces' ,
148
+ {'image_url' : 'https://example.com/image with spaces.jpg' },
149
+ ),
142
150
],
143
151
)
144
152
def test_edit_invalid_image_urls (self , _ , patch_payload ):
@@ -158,21 +166,43 @@ def test_edit_invalid_image_urls(self, _, patch_payload):
158
166
(
159
167
'age_range_invalid' ,
160
168
{
161
- 'description' : 'Bonus 10000%!' ,
162
169
'target' : {'age_from' : 19 , 'age_until' : 17 },
163
170
},
164
171
),
172
+ ('age_from_too_high' , {'target' : {'age_from' : 200 }}),
173
+ ('age_until_too_high' , {'target' : {'age_until' : 200 }}),
174
+ ('age_from_too_low' , {'target' : {'age_from' : - 1 }}),
175
+ ('age_until_too_low' , {'target' : {'age_until' : - 1 }}),
176
+ (
177
+ 'invalid_target_country_format' ,
178
+ {'target' : {'country' : 'USA' }},
179
+ ),
165
180
(
166
- 'incomplete_target' ,
167
- {'description' : 'Bonus 10000%!' , 'target' : {'country' : 'USA' }},
181
+ 'invalid_target_country_too_short' ,
182
+ {'target' : {'country' : 'U' }},
183
+ ),
184
+ (
185
+ 'invalid_target_country_does_not_exist' ,
186
+ {'target' : {'country' : 'XX' }},
168
187
),
169
188
(
170
189
'empty_category' ,
171
190
{
172
- 'description' : 'Bonus 10000%!' ,
173
191
'target' : {'categories' : ['' ]},
174
192
},
175
193
),
194
+ (
195
+ 'non_string_category' ,
196
+ {
197
+ 'target' : {'categories' : [1 , 2 , 3 ]},
198
+ },
199
+ ),
200
+ (
201
+ 'non_dict_target' ,
202
+ {
203
+ 'target' : ['not' , 'a' , 'dict' ],
204
+ },
205
+ ),
176
206
],
177
207
)
178
208
def test_edit_invalid_target (self , _ , patch_payload ):
@@ -225,6 +255,36 @@ def test_edit_invalid_target(self, _, patch_payload):
225
255
'common_payload' ,
226
256
{'max_count' : 100_000_001 },
227
257
),
258
+ (
259
+ 'non_integer_max_count_float' ,
260
+ 'company1_token' ,
261
+ 'common_payload' ,
262
+ {'max_count' : 10.5 },
263
+ ),
264
+ (
265
+ 'max_count_is_empty_string' ,
266
+ 'company1_token' ,
267
+ 'common_payload' ,
268
+ {'max_count' : '' },
269
+ ),
270
+ (
271
+ 'max_count_is_list' ,
272
+ 'company1_token' ,
273
+ 'common_payload' ,
274
+ {'max_count' : [1 , 2 , 3 ]},
275
+ ),
276
+ (
277
+ 'max_count_is_dict' ,
278
+ 'company1_token' ,
279
+ 'common_payload' ,
280
+ {'max_count' : {'key' : 'value' }},
281
+ ),
282
+ (
283
+ 'max_count_is_boolean' ,
284
+ 'company1_token' ,
285
+ 'common_payload' ,
286
+ {'max_count' : True },
287
+ ),
228
288
],
229
289
)
230
290
def test_edit_invalid_max_count (
@@ -268,6 +328,18 @@ def test_get_promo_verify_fields_unchanged(self):
268
328
HTTP_AUTHORIZATION = 'Bearer ' + self .company2_token ,
269
329
)
270
330
url = self .promo_detail_url (promo_id )
331
+ patch_payload = {
332
+ 'active_from' : '2024-12-28 12:00:00' ,
333
+ 'max_count' : 100 ,
334
+ 'description' : 'short' ,
335
+ 'target' : {'age_from' : 26 , 'country' : 'fr' },
336
+ }
337
+ response = self .client .patch (url , patch_payload , format = 'json' )
338
+ self .assertEqual (
339
+ response .status_code ,
340
+ rest_framework .status .HTTP_400_BAD_REQUEST ,
341
+ )
342
+
271
343
response = self .client .get (url , format = 'json' )
272
344
self .assertEqual (
273
345
response .status_code ,
0 commit comments