Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorRogelio Mita <rogeliomita@activitycentral.com>2013-09-19 18:35:48 (GMT)
committer Rogelio Mita <rogeliomita@activitycentral.com>2013-09-19 19:19:07 (GMT)
commit1851df5bc6b0bb69e2c4f32bed4643b7d21bc277 (patch)
tree42a563762864ed2d1be8c783bc6af124b6037ebe /webapp
parent603cf55691f8745e84aeebb7226b92a83898aa73 (diff)
Refactor in test
Diffstat (limited to 'webapp')
-rw-r--r--webapp/polls/tests/structure_tests.py33
1 files changed, 21 insertions, 12 deletions
diff --git a/webapp/polls/tests/structure_tests.py b/webapp/polls/tests/structure_tests.py
index f11da61..2f793c6 100644
--- a/webapp/polls/tests/structure_tests.py
+++ b/webapp/polls/tests/structure_tests.py
@@ -324,15 +324,9 @@ class StructureTests(MongoTestCase):
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 = {
+ def setUp(self):
+ self.option_id = '131212'
+ self.data = {
'groups': {
'0': {
'name': "group name",
@@ -341,8 +335,8 @@ class UploadOptionImagesTest(MongoTestCase):
'name': "field_0_0",
'widget_type': Field.ImageCheckBox,
'options': {
- option_id: {
- 'img': img,
+ self.option_id: {
+ 'img': None,
'text': "text",
'order': 0
}
@@ -354,7 +348,22 @@ class UploadOptionImagesTest(MongoTestCase):
}
poll = Poll({"name": "poll name"})
poll_id = poll.save()
- poll = poll.get(poll_id)
+ self.poll = poll.get(poll_id)
+
+ img_ext = "jpg"
+ self.img_filename = '.'.join([self.option_id, img_ext])
+ self.img = Mock()
+ self.img.chunks = Mock(return_value=['chunk', 'chunk'])
+ self.img.name = self.img_filename
+
+ def test_it_should_save_option_images_with_many_chunks(self):
+ option_id = self.option_id
+ img = self.img
+ img_filename = self.img_filename
+
+ data = self.data
+ data['groups']['0']['fields']['0']['options'][option_id]['img'] = img
+ poll = self.poll
structure = Structure(data=data, poll=poll)
structure.save_image_options()