aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-12-18 20:59:55 -0800
committerGravatar MarkKoz <[email protected]>2019-12-18 21:06:03 -0800
commit8d493899dba790286690126c121fc92658052dcd (patch)
tree091e4bfcaf3b588c7395823cf5344a4beffcdcb7 /pydis_site
parentAdd fixtures to create infractions in serializer tests (diff)
Test that new infractions pass validation
Diffstat (limited to 'pydis_site')
-rw-r--r--pydis_site/apps/api/tests/test_infractions.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/pydis_site/apps/api/tests/test_infractions.py b/pydis_site/apps/api/tests/test_infractions.py
index cacd4d06..da2171d5 100644
--- a/pydis_site/apps/api/tests/test_infractions.py
+++ b/pydis_site/apps/api/tests/test_infractions.py
@@ -612,3 +612,17 @@ class SerializerTests(APISubdomainTestCase):
msg = 'This user already has an active infraction of this type'
with self.assertRaisesRegex(ValidationError, msg):
serializer.is_valid(raise_exception=True)
+
+ def test_is_valid_for_new_active_infraction(self):
+ self.create_infraction('ban', active=False)
+
+ data = {
+ 'user': self.user.id,
+ 'actor': self.user.id,
+ 'type': 'ban',
+ 'reason': 'A reason.',
+ 'active': True
+ }
+ serializer = InfractionSerializer(data=data)
+
+ self.assertTrue(serializer.is_valid())