Skip to content
This repository has been archived by the owner on Feb 13, 2022. It is now read-only.

Commit

Permalink
refactored the polls creation
Browse files Browse the repository at this point in the history
  • Loading branch information
sewagodimo committed Mar 29, 2018
1 parent e87d7ac commit 6e40cd7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 31 deletions.
25 changes: 0 additions & 25 deletions molo/surveys/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,6 @@ def create_survey(fields={}, **kwargs):
return survey


def create_molo_poll(parent, **kwargs):
return create_molo_survey_page(
parent=parent,
title="Molo Survey Poll",
slug="molo-survey-poll",
display_survey_directly=True,
allow_anonymous_submissions=False,
allow_multiple_submissions_per_user=True,
thank_you_text='Thank you for taking the Molo Poll',
)


def create_personalisable_poll(parent, **kwargs):
survey = create_personalisable_survey_page(
parent=parent,
title='Personalisable Survey Poll',
slug="personalisable-survey-poll",
allow_anonymous_submissions=True,
display_survey_directly=True,
allow_multiple_submissions_per_user=True,
thank_you_text='Thank you for taking the Personalisable Poll',
)
return survey


def create_molo_dropddown_field(
parent, survey, choices, page_break=False,
sort_order=1, label="Is this a dropdown?", **kwargs):
Expand Down
16 changes: 10 additions & 6 deletions molo/surveys/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

from .utils import skip_logic_data
from .base import (
create_molo_poll,
create_personalisable_poll,
create_personalisable_survey_page,
create_molo_dropddown_field,
create_personalisable_dropddown_field,
create_molo_survey_formfield,
Expand Down Expand Up @@ -1134,7 +1133,8 @@ def setUp(self):
self.surveys_index = SurveysIndexPage.objects.first()

def test_molo_poll(self):
survey = create_molo_poll(self.surveys_index)
survey = create_molo_survey_page(
self.surveys_index, display_survey_directly=True)
drop_down_field = create_molo_dropddown_field(
self.surveys_index, survey, self.choices)
response = self.client.post(
Expand All @@ -1146,7 +1146,8 @@ def test_molo_poll(self):
self.assertNotContains(response, 'That page number is less than 1')

def test_molo_poll_with_page_break(self):
survey = create_molo_poll(self.surveys_index)
survey = create_molo_survey_page(
self.surveys_index, display_survey_directly=True)
drop_down_field = create_molo_dropddown_field(
self.surveys_index, survey, self.choices, page_break=True)
response = self.client.post(
Expand All @@ -1158,7 +1159,9 @@ def test_molo_poll_with_page_break(self):
self.assertNotContains(response, 'That page number is less than 1')

def test_personalisable_survey_poll(self):
survey = create_personalisable_poll(self.surveys_index)
survey = create_personalisable_survey_page(
self.surveys_index,
display_survey_directly=True)
drop_down_field = create_personalisable_dropddown_field(
self.surveys_index, survey, self.choices)
response = self.client.post(
Expand All @@ -1170,7 +1173,8 @@ def test_personalisable_survey_poll(self):
self.assertNotContains(response, 'That page number is less than 1')

def test_personalisable_survey_poll_with_page_break(self):
survey = create_personalisable_poll(self.surveys_index)
survey = create_personalisable_survey_page(
self.surveys_index, display_survey_directly=True)
drop_down_field = create_personalisable_dropddown_field(
self.surveys_index, survey, self.choices, page_break=True)
response = self.client.post(
Expand Down

0 comments on commit 6e40cd7

Please sign in to comment.