@@ -129,17 +129,16 @@ def test_edit_invalid_short_description(self):
129129 [
130130 (
131131 'non_string' ,
132- {'description' : 'Bonus 10000%!' , ' image_url' : False },
132+ {'image_url' : False },
133133 ),
134134 (
135135 'incomplete_url' ,
136- {'description' : 'Bonus 10000%!' , ' image_url' : 'https://' },
136+ {'image_url' : 'https://' },
137137 ),
138138 (
139139 'malformed_url' ,
140- {'description' : 'Bonus 10000%!' , ' image_url' : 'notalink' },
140+ {'image_url' : 'notalink' },
141141 ),
142- ('incorrect_type' , {'image_url' : 'jpeg' }),
143142 ],
144143 )
145144 def test_edit_invalid_image_urls (self , _ , patch_payload ):
@@ -188,29 +187,63 @@ def test_edit_invalid_target(self, _, patch_payload):
188187 rest_framework .status .HTTP_400_BAD_REQUEST ,
189188 )
190189
191- def test_edit_invalid_max_count_for_unique (self ):
192- promo_id = self .create_promo (self .company2_token , self .unique_payload )
193- self .client .credentials (
194- HTTP_AUTHORIZATION = 'Bearer ' + self .company2_token ,
195- )
196- url = self .promo_detail_url (promo_id )
197- patch_payload = {
198- 'max_count' : 10 ,
199- }
200- response = self .client .patch (url , patch_payload , format = 'json' )
201- self .assertEqual (
202- response .status_code ,
203- rest_framework .status .HTTP_400_BAD_REQUEST ,
204- )
190+ @parameterized .parameterized .expand (
191+ [
192+ (
193+ 'unique_max_count' ,
194+ 'company2_token' ,
195+ 'unique_payload' ,
196+ {'max_count' : 10 },
197+ ),
198+ (
199+ 'negative_max_count' ,
200+ 'company1_token' ,
201+ 'common_payload' ,
202+ {'max_count' : - 10 },
203+ ),
204+ (
205+ 'non_integer_max_count' ,
206+ 'company1_token' ,
207+ 'common_payload' ,
208+ {'max_count' : 'invalid' },
209+ ),
210+ (
211+ 'zero_max_count' ,
212+ 'company2_token' ,
213+ 'unique_payload' ,
214+ {'max_count' : 0 },
215+ ),
216+ (
217+ 'max_count_is_none' ,
218+ 'company1_token' ,
219+ 'common_payload' ,
220+ {'max_count' : None },
221+ ),
222+ (
223+ 'exceeding_max_count' ,
224+ 'company1_token' ,
225+ 'common_payload' ,
226+ {'max_count' : 100_000_001 },
227+ ),
228+ ],
229+ )
230+ def test_edit_invalid_max_count (
231+ self ,
232+ _ ,
233+ token_attr ,
234+ payload_attr ,
235+ patch_payload ,
236+ ):
237+ token = getattr (self , token_attr )
238+ create_payload = getattr (self , payload_attr )
205239
206- def test_edit_negative_max_count (self ):
207- promo_id = self .create_promo (self .company1_token , self .common_payload )
208- self .client .credentials (
209- HTTP_AUTHORIZATION = 'Bearer ' + self .company1_token ,
210- )
240+ promo_id = self .create_promo (token , create_payload )
241+
242+ self .client .credentials (HTTP_AUTHORIZATION = 'Bearer ' + token )
211243 url = self .promo_detail_url (promo_id )
212- patch_payload = { 'max_count' : - 10 }
244+
213245 response = self .client .patch (url , patch_payload , format = 'json' )
246+
214247 self .assertEqual (
215248 response .status_code ,
216249 rest_framework .status .HTTP_400_BAD_REQUEST ,
0 commit comments