aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api/tests
diff options
context:
space:
mode:
authorGravatar Rohan Reddy Alleti <[email protected]>2021-07-24 19:23:12 +0530
committerGravatar GitHub <[email protected]>2021-07-24 19:23:12 +0530
commit33178547e2ecce99ce5b7f6b07e2df246021b48e (patch)
tree878443d95ff2f5ae25b44203682c1df2f94d6181 /pydis_site/apps/api/tests
parentUpdate docstring. (diff)
parentMerge pull request #556 from python-discord/fix-docker-link (diff)
Merge branch 'main' into otn_softdel
Diffstat (limited to 'pydis_site/apps/api/tests')
-rw-r--r--pydis_site/apps/api/tests/test_models.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/pydis_site/apps/api/tests/test_models.py b/pydis_site/apps/api/tests/test_models.py
index 66052e01..5c9ddea4 100644
--- a/pydis_site/apps/api/tests/test_models.py
+++ b/pydis_site/apps/api/tests/test_models.py
@@ -1,6 +1,7 @@
from datetime import datetime as dt
-from django.test import SimpleTestCase
+from django.core.exceptions import ValidationError
+from django.test import SimpleTestCase, TestCase
from django.utils import timezone
from pydis_site.apps.api.models import (
@@ -34,6 +35,43 @@ class ReprMixinTests(SimpleTestCase):
self.assertEqual(repr(self.klass), expected)
+class NitroMessageLengthTest(TestCase):
+ def setUp(self):
+ self.user = User.objects.create(id=50, name='bill', discriminator=5)
+ self.context = MessageDeletionContext.objects.create(
+ id=50,
+ actor=self.user,
+ creation=dt.utcnow()
+ )
+
+ def test_create(self):
+ message = DeletedMessage(
+ id=46,
+ author=self.user,
+ channel_id=666,
+ content="w"*4000,
+ deletion_context=self.context,
+ embeds=[]
+ )
+
+ try:
+ message.clean_fields()
+ except Exception as e: # pragma: no cover
+ self.fail(f"Creation of message of length 3950 failed with: {e}")
+
+ def test_create_failure(self):
+ message = DeletedMessage(
+ id=47,
+ author=self.user,
+ channel_id=666,
+ content="w"*4001,
+ deletion_context=self.context,
+ embeds=[]
+ )
+
+ self.assertRaisesRegex(ValidationError, "content':", message.clean_fields)
+
+
class StringDunderMethodTests(SimpleTestCase):
def setUp(self):
self.nomination = Nomination(