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:
authorRogelio Mita <rogeliomita@activitycentral.com>2013-09-06 15:05:00 (GMT)
committer Rogelio Mita <rogeliomita@activitycentral.com>2013-09-06 15:05:00 (GMT)
commitfcda7858456a731fb227e642c00e922f2b113963 (patch)
tree5eccad4203399669aff8e8d768a05c5ebe18ab42 /webapp/polls/tests/poll_tests.py
parentd5b2a24e14bec4671ba488f62a0d7af9857c4467 (diff)
Refactor: Poll method for check if has result
Diffstat (limited to 'webapp/polls/tests/poll_tests.py')
-rw-r--r--webapp/polls/tests/poll_tests.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/webapp/polls/tests/poll_tests.py b/webapp/polls/tests/poll_tests.py
index 86e2f60..a3f11c5 100644
--- a/webapp/polls/tests/poll_tests.py
+++ b/webapp/polls/tests/poll_tests.py
@@ -378,6 +378,29 @@ class PollTests(MongoTestCase):
poll_result = poll.get_result()
self.assertTrue(hasattr(poll_result, "to_csv"))
+ def test_has_result_with_no_results(self):
+ poll = Poll(data={'name': "poll"})
+ poll_id = poll.save()
+ poll = Poll.get(poll_id)
+
+ self.assertFalse(poll.has_result())
+
+ def test_has_result_with_at_least_one_result(self):
+ poll = Poll(data={'name': "poll"})
+ poll_id = poll.save()
+ poll = Poll.get(poll_id)
+
+ temp_dir = '/tmp'
+ uploaded_file = tempfile.NamedTemporaryFile(dir=temp_dir,
+ suffix='.poll_result')
+ uploaded_file_path = uploaded_file.name
+ uploaded_filename = os.path.basename(uploaded_file_path)
+
+ poll.add_result_files([(uploaded_file_path, uploaded_filename)])
+ stub = lambda path: os.path.basename(path)
+
+ self.assertTrue(poll.has_result(as_instance_of=stub))
+
class PollFormTests(MongoTestCase):