diff options
author | 2021-07-08 21:12:21 +0200 | |
---|---|---|
committer | 2021-07-08 21:12:21 +0200 | |
commit | fa4a8dd77b8792c5f859dd5ccd1c1e70441d0b94 (patch) | |
tree | 3624cd418bd3801b199bb933db38429823c590c0 /pydis_site/apps/api/tests | |
parent | Move subdomains to query paths. (diff) | |
parent | Merge pull request #547 from Numerlor/docker-override (diff) |
Merge branch 'master' into subdomains-to-query-paths
Diffstat (limited to 'pydis_site/apps/api/tests')
-rw-r--r-- | pydis_site/apps/api/tests/test_models.py | 40 |
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( |