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

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
codiebeulaine committed Feb 13, 2018
1 parent c6c6d0d commit 3cc7439
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
8 changes: 0 additions & 8 deletions molo/surveys/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ def create_molo_survey_page(parent, **kwargs):
molo_survey_page = MoloSurveyPage(
title='Test Survey', slug='test-survey',
introduction='Introduction to Test Survey ...',
homepage_introduction='Shorter homepage introduction',
thank_you_text='Thank you for taking the Test Survey',
submit_text='survey submission text',
**kwargs
Expand Down Expand Up @@ -206,13 +205,6 @@ def test_setup2(self):

self.assertEquals(1, MoloSurveyPage.objects.count())

def test_homepage_introduction(self):
survey = create_survey()
survey.allow_anonymous_submissions = True
survey.save()
response = self.client.get('/')
self.assertContains(response, 'Shorter homepage introduction')

def test_two_questions_in_one_step_when_one_required(self):
create_survey([
{
Expand Down
23 changes: 11 additions & 12 deletions molo/surveys/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def create_molo_survey_page(self, parent, **kwargs):
molo_survey_page = MoloSurveyPage(
title='Test Survey', slug='test-survey',
introduction='Introduction to Test Survey ...',
homepage_introduction='Shorter homepage introduction',
thank_you_text='Thank you for taking the Test Survey',
submit_text='survey submission text',
**kwargs
Expand All @@ -96,6 +97,16 @@ def test_homepage_button_text_customisable(self):
self.assertContains(response, 'share your story yo')
self.assertNotContains(response, 'Take the Survey')

def test_correct_intro_shows_on_homepage(self):
molo_survey_page, molo_survey_form_field = \
self.create_molo_survey_page(
parent=self.surveys_index,
homepage_button_text='share your story yo')
self.client.login(username='tester', password='tester')
response = self.client.get('/')
self.assertContains(response, 'Shorter homepage introduction')
self.assertNotContains(response, 'Introduction to Test Survey ...')

def test_anonymous_submissions_not_allowed_by_default(self):
molo_survey_page, molo_survey_form_field = \
self.create_molo_survey_page(parent=self.section_index)
Expand All @@ -113,7 +124,6 @@ def test_submit_survey_as_logged_in_user(self):

response = self.client.get(molo_survey_page.url)
self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)
self.assertContains(response, molo_survey_page.submit_text)

Expand All @@ -136,7 +146,6 @@ def test_anonymous_submissions_option(self):
response = self.client.get(molo_survey_page.url)

self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)
response = self.client.post(molo_survey_page.url, {
molo_survey_form_field.label.lower().replace(' ', '-'): 'python'
Expand Down Expand Up @@ -177,7 +186,6 @@ def test_multiple_submissions_option(self, anonymous=False):
response = self.client.get(molo_survey_page.url)

self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)

response = self.client.post(molo_survey_page.url, {
Expand All @@ -200,7 +208,6 @@ def test_show_results_option(self):

response = self.client.get(molo_survey_page.url)
self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)

response = self.client.post(molo_survey_page.url, {
Expand All @@ -223,7 +230,6 @@ def test_show_results_as_percentage_option(self):

response = self.client.get(molo_survey_page.url)
self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)

response = self.client.post(molo_survey_page.url, {
Expand Down Expand Up @@ -261,7 +267,6 @@ def test_multi_step_option(self):
response = self.client.get(molo_survey_page.url)

self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)
self.assertNotContains(response, extra_molo_survey_form_field.label)
self.assertContains(response, 'Next Question')
Expand All @@ -271,7 +276,6 @@ def test_multi_step_option(self):
})

self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.introduction)
self.assertNotContains(response, molo_survey_form_field.label)
self.assertContains(response, extra_molo_survey_form_field.label)
self.assertContains(response, molo_survey_page.submit_text)
Expand All @@ -296,7 +300,6 @@ def test_can_submit_after_validation_error(self):
response = self.client.get(molo_survey_page.url)

self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)

response = self.client.post(molo_survey_page.url, {})
Expand Down Expand Up @@ -326,7 +329,6 @@ def test_survey_template_tag_on_home_page_specific(self):
self.create_molo_survey_page(parent=self.surveys_index)
response = self.client.get("/")
self.assertContains(response, 'Take The Survey</a>')
self.assertContains(response, molo_survey_page.introduction)
user = User.objects.create_superuser(
username='testuser', password='password', email='test@email.com')
self.client2.login(user=user)
Expand All @@ -338,7 +340,6 @@ def test_can_only_see_sites_surveys_in_admin(self):
self.create_molo_survey_page(parent=self.surveys_index)
response = self.client.get("/")
self.assertContains(response, 'Take The Survey</a>')
self.assertContains(response, molo_survey_page.introduction)
user = User.objects.create_superuser(
username='testuser', password='password', email='test@email.com')
self.client2.login(user=user)
Expand Down Expand Up @@ -443,7 +444,6 @@ def test_survey_template_tag_on_section_page(self):

response = self.client.get(self.section.url)
self.assertContains(response, 'Take The Survey</a>')
self.assertContains(response, molo_survey_page.introduction)

def test_translated_survey_on_section_page(self):
self.user = self.login()
Expand Down Expand Up @@ -481,7 +481,6 @@ def test_survey_template_tag_on_article_page(self):
self.assertContains(response,
'Take The Survey</a>'.format(
molo_survey_page.url))
self.assertContains(response, molo_survey_page.introduction)

def test_survey_list_display_direct_logged_out(self):
molo_survey_page, molo_survey_form_field = \
Expand Down

0 comments on commit 3cc7439

Please sign in to comment.