diff options
Diffstat (limited to 'webapp/polls/tests/structure_tests.py')
-rw-r--r-- | webapp/polls/tests/structure_tests.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/webapp/polls/tests/structure_tests.py b/webapp/polls/tests/structure_tests.py index aeb8702..c9fe0d9 100644 --- a/webapp/polls/tests/structure_tests.py +++ b/webapp/polls/tests/structure_tests.py @@ -314,6 +314,14 @@ class StructureTests(MongoTestCase): def test_it_should_respond_to_ready_only_msg(self): self.assertTrue(hasattr(Structure, 'READ_ONLY_MSG')) + +class ReadOnlyTest(MongoTestCase): + + def setUp(self): + poll = Poll({"name": "poll name"}) + poll_id = poll.save() + self.poll = poll.get(poll_id) + def test_it_should_be_read_only_when_poll_has_results(self): poll = self.poll structure = Structure(data={}, poll=poll) @@ -324,6 +332,18 @@ class StructureTests(MongoTestCase): self.assertTrue(poll.has_result()) self.assertTrue(structure.is_read_only()) + def test_read_only_when_poll_is_closed_and_has_not_results(self): + poll = self.poll + poll.status = Poll.CLOSED + poll_id = poll.save() + poll = poll.get(poll_id) + + structure = Structure(data={}, poll=poll) + self.assertFalse(poll.has_result()) + self.assertFalse(poll.is_open()) + + self.assertTrue(structure.is_read_only()) + class UploadOptionImagesTest(MongoTestCase): |