@@ -327,6 +327,18 @@ def test_partial_update(self):
327327 self .assertEqual (infraction .type , self .ban_hidden .type )
328328 self .assertEqual (infraction .hidden , self .ban_hidden .hidden )
329329
330+ def test_partial_update_of_inactive_infraction (self ):
331+ url = reverse ('api:bot:infraction-detail' , args = (self .ban_hidden .id ,))
332+ data = {
333+ 'expires_at' : '4143-02-15T21:04:31+00:00' ,
334+ 'reason' : "Do not help out Joe with any electricity-related questions"
335+ }
336+ self .assertFalse (self .ban_inactive .active , "Infraction should start out as inactive" )
337+ response = self .client .patch (url , data = data )
338+ self .assertEqual (response .status_code , 200 )
339+ infraction = Infraction .objects .get (id = self .ban_inactive .id )
340+ self .assertFalse (infraction .active , "Infraction changed to active via patch" )
341+
330342 def test_partial_update_returns_400_for_frozen_field (self ):
331343 url = reverse ('api:bot:infraction-detail' , args = (self .ban_hidden .id ,))
332344 data = {'user' : 6 }
@@ -692,6 +704,37 @@ def test_integrity_error_if_missing_active_field(self):
692704 reason = 'A reason.' ,
693705 )
694706
707+ def test_accepts_two_warnings (self ):
708+ """Two warnings can be created for a user."""
709+ url = reverse ('api:bot:infraction-list' )
710+ data = {
711+ 'user' : self .user .id ,
712+ 'actor' : self .user .id ,
713+ 'type' : 'warning' ,
714+ 'reason' : "Thought upgrading DRF is a smart idea" ,
715+ 'active' : False ,
716+ }
717+ first_response = self .client .post (url , data = data )
718+ self .assertEqual (first_response .status_code , 201 )
719+ data ['reason' ] = "Do not claim King Arthur eats children"
720+ second_response = self .client .post (url , data = data )
721+ self .assertEqual (second_response .status_code , 201 )
722+
723+ def test_respects_active_false_of_warnings (self ):
724+ """Infractions can be created as inactive."""
725+ url = reverse ('api:bot:infraction-list' )
726+ data = {
727+ 'user' : self .user .id ,
728+ 'actor' : self .user .id ,
729+ 'type' : 'warning' ,
730+ 'reason' : "Associate of REDACTED" ,
731+ 'active' : False ,
732+ }
733+ response = self .client .post (url , data = data )
734+ self .assertEqual (response .status_code , 201 )
735+ infraction = Infraction .objects .get (id = response .json ()['id' ])
736+ self .assertFalse (infraction .active )
737+
695738
696739class InfractionDeletionTests (AuthenticatedAPITestCase ):
697740 @classmethod
0 commit comments