Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/webapp/polls/tests/poll_tests.py
diff options
context:
space:
mode:
authorCode Raguet <ignacio.code@gmail.com>2013-09-11 22:25:49 (GMT)
committer Code Raguet <ignacio.code@gmail.com>2013-09-11 22:44:19 (GMT)
commite6ac217b80475183d066cab365e995d70477ac46 (patch)
tree7ae97fb4501015afa2309455b7eed93d308a687d /webapp/polls/tests/poll_tests.py
parent80548f4fbb4e5ec8cb1bff63ba72511ad9958e4e (diff)
add delete to PollResultFile and add remove_results to Poll
Diffstat (limited to 'webapp/polls/tests/poll_tests.py')
-rw-r--r--webapp/polls/tests/poll_tests.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/webapp/polls/tests/poll_tests.py b/webapp/polls/tests/poll_tests.py
index a3f11c5..53446cd 100644
--- a/webapp/polls/tests/poll_tests.py
+++ b/webapp/polls/tests/poll_tests.py
@@ -13,6 +13,7 @@ from django.conf import settings
from django.test import TestCase
from utils.test import MongoTestCase
+from polls.tests.poll_result_file_tests import make_temp_file
class PollTests(MongoTestCase):
@@ -505,3 +506,27 @@ class CleanDataMustCheckImagesTypes(TestCase):
data_to_clean = {'value': " to strip "}
cleaned_data = clean_data(data_to_clean)
self.assertEqual("to strip", cleaned_data['value'])
+
+
+class RemoveResultsTest(MongoTestCase):
+
+ def test_it_should_respond_to_remove_results(self):
+ name = 'poll'
+ data = {'name': name}
+ poll = Poll(data=data)
+ self.assertTrue(hasattr(poll, 'remove_results'))
+
+ def test_it_should_remove_the_result_files(self):
+ data = {}
+ uploaded_file_path = make_temp_file(data)
+ uploaded_filename = os.path.basename(uploaded_file_path)
+
+ poll = Poll(data={'name': "poll"})
+ poll_id = poll.save()
+ poll = Poll.get(poll_id)
+
+ poll.add_result_files([(uploaded_file_path, uploaded_filename)])
+ self.assertEqual(1, len(poll.get_result_files()))
+
+ poll.remove_results()
+ self.assertEqual(0, len(poll.get_result_files()))