Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/webapp/polls/tests/structure_tests.py
diff options
context:
space:
mode:
authorCode Raguet <ignacio.code@gmail.com>2013-09-16 21:29:03 (GMT)
committer Code Raguet <ignacio.code@gmail.com>2013-09-16 21:31:11 (GMT)
commitf4aeeb7d71027f672d523d06a5d2c43ce474124a (patch)
treea02fea5a45019696eb378365207d545d02f19756 /webapp/polls/tests/structure_tests.py
parent4b4fb05191a601dd21d59e5f0b88c0afc985d08d (diff)
test for bugfix: "images with many chunks
Diffstat (limited to 'webapp/polls/tests/structure_tests.py')
-rw-r--r--webapp/polls/tests/structure_tests.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/webapp/polls/tests/structure_tests.py b/webapp/polls/tests/structure_tests.py
index e7ee213..abb7bd8 100644
--- a/webapp/polls/tests/structure_tests.py
+++ b/webapp/polls/tests/structure_tests.py
@@ -1,5 +1,8 @@
# -*- encoding: utf-8 -*-
+import os
+
from polls.models import Poll, Group, Field, Structure
+from mock import Mock
from utils.test import MongoTestCase, mock_in_memory_image
from polls.tests.poll_tests import MockImageFileInterface
@@ -316,3 +319,45 @@ class StructureTests(MongoTestCase):
structure = Structure(data=data, poll=poll)
self.assertEqual(1, len(structure.get_image_options()))
+
+
+class UploadOptionImagesTest(MongoTestCase):
+
+ def test_it_should_save_option_images_with_many_chunks(self):
+ option_id = '131212'
+ img_ext = "jpg"
+ img_filename = '.'.join([option_id, img_ext])
+ img = Mock()
+ img.chunks = Mock(return_value=['chunk', 'chunk'])
+ img.name = img_filename
+
+ data = {
+ 'groups': {
+ '0': {
+ 'name': "group name",
+ 'fields': {
+ '0': {
+ 'name': "field_0_0",
+ 'widget_type': Field.ImageCheckBox,
+ 'options': {
+ option_id: {
+ 'img': img,
+ 'text': "text",
+ 'order': 0
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ poll = Poll({"name": "poll name"})
+ poll_id = poll.save()
+ poll = poll.get(poll_id)
+ structure = Structure(data=data, poll=poll)
+
+ structure.save_image_options()
+
+ images_dir = structure.get_image_options_path()
+ saved_on_disk = os.path.exists(os.path.join(images_dir, img_filename))
+ self.assertTrue(saved_on_disk)