aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polyconseil.fr>2013-07-02 11:14:08 +0200
committerRaphaël Barrois <raphael.barrois@polyconseil.fr>2013-07-02 11:31:00 +0200
commit5b285bca1f6572d4eda7fb04fe7d4d4fef33ab0b (patch)
tree07fe7d8de673815376b25cf11330d52ee1537eb1 /tests
parent0a35ba85329803ef39028edb238d5b5241585128 (diff)
downloadfactory-boy-5b285bca1f6572d4eda7fb04fe7d4d4fef33ab0b.tar
factory-boy-5b285bca1f6572d4eda7fb04fe7d4d4fef33ab0b.tar.gz
Fix default color for factory.django.ImageField
Diffstat (limited to 'tests')
-rw-r--r--tests/test_django.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/test_django.py b/tests/test_django.py
index 05ee961..5335a94 100644
--- a/tests/test_django.py
+++ b/tests/test_django.py
@@ -51,6 +51,7 @@ if django is not None:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.djapp.settings')
from django import test as django_test
+ from django.conf import settings
from django.db import models as django_models
from django.test import simple as django_test_simple
from django.test import utils as django_test_utils
@@ -306,12 +307,31 @@ class DjangoImageFieldTestCase(unittest.TestCase):
self.assertEqual('django/example.jpg', o.animage.name)
def test_with_content(self):
- o = WithImageFactory.build(animage__width=13, animage__color='blue')
+ o = WithImageFactory.build(animage__width=13, animage__color='red')
self.assertIsNone(o.pk)
self.assertEqual(13, o.animage.width)
self.assertEqual(13, o.animage.height)
self.assertEqual('django/example.jpg', o.animage.name)
+ i = Image.open(os.path.join(settings.MEDIA_ROOT, o.animage.name))
+ colors = i.getcolors()
+ # 169 pixels with rgb(254, 0, 0)
+ self.assertEqual([(169, (254, 0, 0))], colors)
+ self.assertEqual('JPEG', i.format)
+
+ def test_gif(self):
+ o = WithImageFactory.build(animage__width=13, animage__color='blue', animage__format='GIF')
+ self.assertIsNone(o.pk)
+ self.assertEqual(13, o.animage.width)
+ self.assertEqual(13, o.animage.height)
+ self.assertEqual('django/example.jpg', o.animage.name)
+
+ i = Image.open(os.path.join(settings.MEDIA_ROOT, o.animage.name))
+ colors = i.getcolors()
+ # 169 pixels with color 190 from the GIF palette
+ self.assertEqual([(169, 190)], colors)
+ self.assertEqual('GIF', i.format)
+
def test_with_file(self):
with open(testdata.TESTIMAGE_PATH, 'rb') as f:
o = WithImageFactory.build(animage__from_file=f)