diff options
| author | Berker Peksag <berker.peksag@gmail.com> | 2016-03-26 22:09:08 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-06-30 09:08:50 -0400 |
| commit | 12b4280444b58c94197255655e284e4103fe00a9 (patch) | |
| tree | 26640543f44e65800ae0fbb59004e9e7907bdf73 /tests/model_fields | |
| parent | c9d0a0f7f47c8496a9d8b0cfda94e2ef118d9ab3 (diff) | |
Fixed #21548 -- Added FileExtensionValidator and validate_image_file_extension.
Diffstat (limited to 'tests/model_fields')
| -rw-r--r-- | tests/model_fields/test_imagefield.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/model_fields/test_imagefield.py b/tests/model_fields/test_imagefield.py index f9ae83b8b2..51f91d90c0 100644 --- a/tests/model_fields/test_imagefield.py +++ b/tests/model_fields/test_imagefield.py @@ -4,7 +4,7 @@ import os import shutil from unittest import skipIf -from django.core.exceptions import ImproperlyConfigured +from django.core.exceptions import ImproperlyConfigured, ValidationError from django.core.files import File from django.core.files.images import ImageFile from django.test import TestCase @@ -133,6 +133,12 @@ class ImageFieldTests(ImageFieldTestMixin, TestCase): self.assertEqual(hash(p1_db.mugshot), hash(p1.mugshot)) self.assertIs(p1_db.mugshot != p1.mugshot, False) + def test_validation(self): + p = self.PersonModel(name="Joan") + p.mugshot.save("shot.txt", self.file1) + with self.assertRaisesMessage(ValidationError, "File extension 'txt' is not allowed."): + p.full_clean() + def test_instantiate_missing(self): """ If the underlying file is unavailable, still create instantiate the |
