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

Commit

Permalink
extend coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
moh-moola committed Aug 3, 2018
1 parent 4e1eccc commit 5ab67c7
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions molo/surveys/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,63 @@ def test_survey_index_view_displays_all_surveys(self):
self.assertContains(response, child_of_index_page.title)
self.assertContains(response, child_of_article_page.title)

def test_survey_choices_edit_view(self):
self.client.force_login(self.super_user)
child_of_index_page = create_molo_survey_page(
self.surveys_index,
title="Child of SurveysIndexPage Survey",
slug="child-of-surveysindexpage-survey"
)
form_field = MoloSurveyFormField.objects.create(
page=child_of_index_page, field_type='checkbox', choices='')

response = self.client.get(
'/admin/pages/%d/edit/' % child_of_index_page.pk)
self.assertEqual(response.status_code, 200)

form = response.context['form']
data = form.initial
data.update(
form.formsets['survey_form_fields'].management_form.initial)
data.update({u'description-count': 0})

data.update({
'survey_form_fields-0-admin_label': 'a',
'survey_form_fields-0-label': 'a',
'survey_form_fields-0-default_value': 'a',
'survey_form_fields-0-field_type': form_field.field_type,
'survey_form_fields-0-help_text': 'a',
'survey_form_fields-0-id': form_field.pk,
'go_live_at': '',
'expire_at': '',
'image': '',
'survey_form_fields-0-ORDER': 1,
'survey_form_fields-0-required': 'on',
'survey_form_fields-0-skip_logic-0-deleted': '',
'survey_form_fields-0-skip_logic-0-id': 'None',
'survey_form_fields-0-skip_logic-0-order': 0,
'survey_form_fields-0-skip_logic-0-type': 'skip_logic',
'survey_form_fields-0-skip_logic-0-value-choice': 'a',
'survey_form_fields-0-skip_logic-0-value-question_0': 'a',
'survey_form_fields-0-skip_logic-0-value-skip_logic': 'next',
'survey_form_fields-0-skip_logic-0-value-survey': '',
'survey_form_fields-0-skip_logic-count': 1,
'survey_form_fields-INITIAL_FORMS': 1,
'survey_form_fields-MAX_NUM_FORMS': 1000,
'survey_form_fields-MIN_NUM_FORMS': 0,
'survey_form_fields-TOTAL_FORMS': 1,
'terms_and_conditions-INITIAL_FORMS': 0,
'terms_and_conditions-MAX_NUM_FORMS': 1000,
'terms_and_conditions-MIN_NUM_FORMS': 0,
'terms_and_conditions-TOTAL_FORMS': 0,
})
response = self.client.post(
'/admin/pages/%d/edit/' % child_of_index_page.pk, data=data)
self.assertEqual(response.status_code, 200)

form = response.context['form'].formsets['survey_form_fields']
self.assertTrue(form.errors[0]['field_type'])

def test_survey_edit_view(self):
self.client.force_login(self.super_user)
child_of_index_page = create_molo_survey_page(
Expand Down

0 comments on commit 5ab67c7

Please sign in to comment.