diff options
author | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-09-06 13:59:42 (GMT) |
---|---|---|
committer | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-09-06 13:59:42 (GMT) |
commit | c6a7d3452def0161c4f78bedf11c628c4a61b1c4 (patch) | |
tree | fb52cdeb81e830a7093754c91b6c0730e7626f4d /webapp/polls/tests/poll_tests.py | |
parent | c2e040258dfb4e0524a819ce90540b622af16178 (diff) |
BugFix: Bad way to recognize one image uploaded
Diffstat (limited to 'webapp/polls/tests/poll_tests.py')
-rw-r--r-- | webapp/polls/tests/poll_tests.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/webapp/polls/tests/poll_tests.py b/webapp/polls/tests/poll_tests.py index ac94bc8..86e2f60 100644 --- a/webapp/polls/tests/poll_tests.py +++ b/webapp/polls/tests/poll_tests.py @@ -6,9 +6,11 @@ from bson import ObjectId import os from polls.models import Poll, Field, Structure +from polls.views import clean_data, is_image_file from polls.forms import PollForm from pollster.models import Pollster from django.conf import settings +from django.test import TestCase from utils.test import MongoTestCase @@ -455,3 +457,28 @@ class AddResultFilesTest(MongoTestCase): results = poll.get_result_files(as_instance_of=stub) result_filename = results[0] self.assertEqual(uploaded_filename, result_filename) + + +class MockImageFileInterface(object): + + def __init__(self): + self.name = "a_name.jpg" + + +class CleanDataMustCheckImagesTypes(TestCase): + + def test_is_image(self): + image_mock = MockImageFileInterface() + self.assertTrue(is_image_file(image_mock)) + + def test_it_should_no_raises_with_a_image_file_value(self): + data_to_clean = {'some_img': MockImageFileInterface()} + try: + clean_data(data_to_clean) + except AttributeError as e: + self.fail(e) + + def test_it_should_strip_values_that_are_not_image_files(self): + data_to_clean = {'value': " to strip "} + cleaned_data = clean_data(data_to_clean) + self.assertEqual("to strip", cleaned_data['value']) |