Esempio n. 1
0
class SkipLogicPaginatorPageBreak(TestCase, MoloTestCaseMixin):
    def setUp(self):
        self.mk_main()
        self.survey = MoloSurveyPage(
            title='Test Survey',
            slug='test-survey',
        )
        self.section_index.add_child(instance=self.survey)
        self.survey.save_revision().publish()
        self.first_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=1,
            label='Your other favourite animal',
            field_type='singleline',
            required=True,
            page_break=True,
        )
        self.second_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=2,
            label='Your favourite animal',
            field_type='singleline',
            required=True,
            page_break=True,
        )
        self.last_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=3,
            label='Your least favourite animal',
            field_type='singleline',
            required=True
        )
        self.paginator = SkipLogicPaginator(self.survey.get_form_fields())

    def test_correct_num_pages(self):
        self.assertEqual(self.paginator.num_pages, 3)

    def test_page_breaks_correct(self):
        self.assertEqual(self.paginator.page_breaks, [0, 1, 2, 3])

    def test_first_page_correct(self):
        self.assertEqual(
            self.paginator.page(1).object_list,
            [self.first_field],
        )

    def test_middle_page_correct(self):
        self.assertEqual(
            self.paginator.page(2).object_list,
            [self.second_field],
        )

    def test_last_page_correct(self):
        last_page = self.paginator.page(3)
        self.assertEqual(last_page.object_list, [self.last_field])
        self.assertFalse(last_page.has_next())
Esempio n. 2
0
class SkipLogicPaginatorPageBreak(TestCase, MoloTestCaseMixin):
    def setUp(self):
        self.mk_main()
        self.survey = MoloSurveyPage(
            title='Test Survey',
            slug='test-survey',
        )
        self.section_index.add_child(instance=self.survey)
        self.survey.save_revision().publish()
        self.first_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=1,
            label='Your other favourite animal',
            field_type='singleline',
            required=True,
            page_break=True,
        )
        self.second_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=2,
            label='Your favourite animal',
            field_type='singleline',
            required=True,
            page_break=True,
        )
        self.last_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=3,
            label='Your least favourite animal',
            field_type='singleline',
            required=True)
        self.paginator = SkipLogicPaginator(self.survey.get_form_fields())

    def test_correct_num_pages(self):
        self.assertEqual(self.paginator.num_pages, 3)

    def test_page_breaks_correct(self):
        self.assertEqual(self.paginator.page_breaks, [0, 1, 2, 3])

    def test_first_page_correct(self):
        self.assertEqual(
            self.paginator.page(1).object_list,
            [self.first_field],
        )

    def test_middle_page_correct(self):
        self.assertEqual(
            self.paginator.page(2).object_list,
            [self.second_field],
        )

    def test_last_page_correct(self):
        last_page = self.paginator.page(3)
        self.assertEqual(last_page.object_list, [self.last_field])
        self.assertFalse(last_page.has_next())
Esempio n. 3
0
class TestSkipLogicBlock(TestCase, MoloTestCaseMixin):
    def setUp(self):
        self.mk_main()
        self.survey = MoloSurveyPage(
            title='Test Survey',
            slug='test-survey',
        )
        self.section_index.add_child(instance=self.survey)
        self.survey.save_revision().publish()

    def test_survey_raises_error_if_no_object(self):
        block = SkipLogicBlock()
        data = skip_logic_block_data(
            'next survey',
            SkipState.SURVEY,
            survey=None,
        )
        with self.assertRaises(ValidationError):
            block.clean(data)

    def test_survey_passes_with_object(self):
        block = SkipLogicBlock()
        data = skip_logic_block_data(
            'next survey',
            SkipState.SURVEY,
            survey=self.survey.id,
        )
        cleaned_data = block.clean(data)
        self.assertEqual(cleaned_data['skip_logic'], SkipState.SURVEY)
        self.assertEqual(cleaned_data['survey'], self.survey)

    def test_question_raises_error_if_no_object(self):
        block = SkipLogicBlock()
        data = skip_logic_block_data(
            'a question',
            SkipState.QUESTION,
            question=None,
        )
        with self.assertRaises(ValidationError):
            block.clean(data)

    def test_question_passes_with_object(self):
        block = SkipLogicBlock()
        data = skip_logic_block_data(
            'a question',
            SkipState.QUESTION,
            question=1,
        )
        cleaned_data = block.clean(data)
        self.assertEqual(cleaned_data['skip_logic'], SkipState.QUESTION)
        self.assertEqual(cleaned_data['question'], 1)
Esempio n. 4
0
    def create_molo_survey_form_field(self, field_type):
        survey = MoloSurveyPage(
            title='Test Survey',
            introduction='Introduction to Test Survey ...',
        )
        SurveysIndexPage.objects.first().add_child(instance=survey)
        survey.save_revision().publish()

        return MoloSurveyFormField.objects.create(
            page=survey,
            label="When is your birthday",
            field_type=field_type,
            admin_label="birthday",
        )
Esempio n. 5
0
def create_molo_survey_page(
        parent, title="Test Survey", slug='test-survey',
        thank_you_text='Thank you for taking the Test Survey',
        homepage_introduction='Shorter homepage introduction',
        **kwargs):
    molo_survey_page = MoloSurveyPage(
        title=title, slug=slug,
        introduction='Introduction to Test Survey ...',
        thank_you_text=thank_you_text,
        submit_text='survey submission text',
        homepage_introduction=homepage_introduction, **kwargs
    )

    parent.add_child(instance=molo_survey_page)
    molo_survey_page.save_revision().publish()

    return molo_survey_page
    def create_molo_survey_page(self, parent, **kwargs):
        molo_survey_page = MoloSurveyPage(
            title='Test Survey',
            slug='test-survey',
            introduction='Introduction to Test Survey ...',
            thank_you_text='Thank you for taking the Test Survey',
            submit_text='survey submission text',
            **kwargs)

        parent.add_child(instance=molo_survey_page)
        molo_survey_page.save_revision().publish()
        molo_survey_form_field = MoloSurveyFormField.objects.create(
            page=molo_survey_page,
            sort_order=1,
            label='Your favourite animal',
            field_type='singleline',
            required=True)
        return molo_survey_page, molo_survey_form_field
Esempio n. 7
0
    def create_molo_survey_page(self, parent, **kwargs):
        molo_survey_page = MoloSurveyPage(
            title='Test Survey', slug='test-survey',
            introduction='Introduction to Test Survey ...',
            thank_you_text='Thank you for taking the Test Survey',
            submit_text='survey submission text',
            **kwargs
        )

        parent.add_child(instance=molo_survey_page)
        molo_survey_page.save_revision().publish()
        molo_survey_form_field = MoloSurveyFormField.objects.create(
            page=molo_survey_page,
            sort_order=1,
            label='Your favourite animal',
            field_type='singleline',
            required=True
        )
        return molo_survey_page, molo_survey_form_field
Esempio n. 8
0
def create_molo_survey_page(
        parent,
        title="Test Survey",
        slug='test-survey',
        thank_you_text='Thank you for taking the Test Survey',
        homepage_introduction='Shorter homepage introduction',
        **kwargs):
    molo_survey_page = MoloSurveyPage(
        title=title,
        slug=slug,
        introduction='Introduction to Test Survey ...',
        thank_you_text=thank_you_text,
        submit_text='survey submission text',
        homepage_introduction=homepage_introduction,
        **kwargs)

    parent.add_child(instance=molo_survey_page)
    molo_survey_page.save_revision().publish()

    return molo_survey_page
Esempio n. 9
0
class TestSkipLogicEveryPage(TestCase, MoloTestCaseMixin):
    def setUp(self):
        self.mk_main()
        self.survey = MoloSurveyPage(
            title='Test Survey',
            slug='test-survey',
        )
        self.another_survey = MoloSurveyPage(
            title='Another Test Survey',
            slug='another-test-survey',
        )
        self.section_index.add_child(instance=self.survey)
        self.survey.save_revision().publish()
        self.section_index.add_child(instance=self.another_survey)
        self.another_survey.save_revision().publish()
        field_choices = ['next', 'end']
        self.fourth_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=4,
            label='A random animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(
                field_choices,
                field_choices,
            ),
            required=True)
        self.first_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=1,
            label='Your other favourite animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(
                field_choices + ['question', 'survey'],
                field_choices + ['question', 'survey'],
                question=self.fourth_field,
                survey=self.another_survey,
            ),
            required=True)
        self.second_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=2,
            label='Your favourite animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(
                field_choices,
                field_choices,
            ),
            required=True)
        self.third_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=3,
            label='Your least favourite animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(
                field_choices,
                field_choices,
            ),
            required=True)
        self.paginator = SkipLogicPaginator(self.survey.get_form_fields())

    def test_initialises_correctly(self):
        self.assertEqual(self.paginator.page_breaks, [0, 1, 2, 3, 4])
        self.assertEqual(self.paginator.num_pages, 4)

    def test_first_question_skip_to_last(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            {self.first_field.clean_name: 'question'},
        )
        self.assertEqual(paginator.previous_page, 1)
        self.assertEqual(paginator.next_page, 4)
        page = paginator.page(paginator.next_page)
        self.assertEqual(page.object_list, [self.fourth_field])
        self.assertEqual(page.number, 4)

    def test_first_question_skip_to_next(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            {self.first_field.clean_name: 'next'},
        )
        self.assertEqual(paginator.previous_page, 1)
        self.assertEqual(paginator.next_page, 2)
        page = paginator.page(paginator.next_page)
        self.assertEqual(page.object_list, [self.second_field])
        self.assertEqual(page.number, 2)

    def test_first_question_skip_to_survey(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            {self.first_field.clean_name: 'survey'},
        )
        self.assertEqual(paginator.previous_page, 1)
        page = paginator.page(1)
        self.assertFalse(page.has_next())
Esempio n. 10
0
class TestSkipLogicPaginator(TestCase, MoloTestCaseMixin):
    def setUp(self):
        self.mk_main()
        self.survey = MoloSurveyPage(
            title='Test Survey',
            slug='test-survey',
        )
        self.section_index.add_child(instance=self.survey)
        self.survey.save_revision().publish()
        self.first_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=1,
            label='Your other favourite animal',
            field_type='singleline',
            required=True)
        self.fourth_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=4,
            label='A random animal',
            field_type='singleline',
            required=True)
        field_choices = ['next', 'end', 'question']
        self.second_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=2,
            label='Your favourite animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(
                field_choices,
                field_choices,
                question=self.fourth_field,
            ),
            required=True)
        self.third_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=3,
            label='Your least favourite animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(
                field_choices,
                field_choices,
                question=self.fourth_field,
            ),
            required=True)
        self.paginator = SkipLogicPaginator(self.survey.get_form_fields())

    def test_correct_num_pages(self):
        self.assertEqual(self.paginator.num_pages, 3)

    def test_page_breaks_correct(self):
        self.assertEqual(self.paginator.page_breaks, [0, 2, 3, 4])

    def test_first_page_correct(self):
        page = self.paginator.page(1)
        self.assertEqual(
            page.object_list,
            [self.first_field, self.second_field],
        )
        self.assertTrue(page.has_next())

    def test_second_page_correct(self):
        page = self.paginator.page(2)
        self.assertEqual(page.object_list, [self.third_field])
        self.assertTrue(page.has_next())

    def test_last_page_correct(self):
        last_page = self.paginator.page(3)
        self.assertEqual(last_page.object_list, [self.fourth_field])
        self.assertFalse(last_page.has_next())

    def test_is_end_if_skip_logic(self):
        paginator = SkipLogicPaginator(self.survey.get_form_fields(),
                                       {self.second_field.clean_name: 'end'})
        first_page = paginator.page(1)
        self.assertFalse(first_page.has_next())

    def test_skip_question_if_skip_logic(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            {self.second_field.clean_name: 'question'})
        page = paginator.page(1)
        next_page_number = page.next_page_number()
        self.assertEqual(next_page_number, 3)
        second_page = paginator.page(next_page_number)
        self.assertEqual(second_page.object_list, [self.fourth_field])

    def test_first_question_skip_to_next(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            {self.second_field.clean_name: 'next'},
        )
        self.assertEqual(paginator.previous_page, 1)
        self.assertEqual(paginator.next_page, 2)
        page = paginator.page(paginator.next_page)
        self.assertEqual(page.object_list, [self.third_field])
        self.assertEqual(page.number, 2)

    def test_previous_page_if_skip_a_page(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(), {
                self.first_field.clean_name: 'python',
                self.second_field.clean_name: 'question',
            })
        page = paginator.page(1)
        next_page_number = page.next_page_number()
        self.assertEqual(next_page_number, 3)
        second_page = paginator.page(next_page_number)
        previous_page_number = second_page.previous_page_number()
        self.assertEqual(previous_page_number, 1)
        self.assertEqual(
            paginator.page(previous_page_number).object_list,
            [self.first_field, self.second_field],
        )

    def test_question_progression_index(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(), {
                self.first_field.clean_name: 'python',
                self.second_field.clean_name: 'question',
            })
        self.assertEqual(paginator.previous_page, 1)
        self.assertEqual(paginator.last_question_index, 1)
        self.assertEqual(paginator.next_page, 3)
        self.assertEqual(paginator.next_question_index, 3)

    def test_no_data_index(self):
        paginator = SkipLogicPaginator(self.survey.get_form_fields())
        self.assertEqual(paginator.previous_page, 1)
        self.assertEqual(paginator.next_page, 1)
        self.assertEqual(paginator.next_question_index, 0)

    def test_no_data_index_with_checkbox(self):
        self.first_field.field_type = 'checkbox'
        self.first_field.skip_logic = skip_logic_data(
            ['', ''],
            ['next', 'end'],
        )
        self.first_field.save()
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            data={'csrf': 'dummy'},
        )
        self.assertEqual(paginator.previous_page, 1)
        self.assertEqual(paginator.last_question_index, 0)
        self.assertEqual(paginator.next_page, 2)
        self.assertEqual(paginator.next_question_index, 1)

    def test_single_question_quiz_with_skip_logic_pages_correctly(self):
        self.first_field.delete()
        self.third_field.delete()
        self.fourth_field.delete()
        paginator = SkipLogicPaginator(self.survey.get_form_fields())
        self.assertEqual(paginator.num_pages, 1)
Esempio n. 11
0
class TestSkipLogicMixin(TestCase, MoloTestCaseMixin):
    def setUp(self):
        self.mk_main()
        self.field_choices = ['old', 'this', 'is']
        self.survey = MoloSurveyPage(
            title='Test Survey',
            slug='test-survey',
        )
        self.section_index.add_child(instance=self.survey)
        self.survey.save_revision().publish()
        self.choice_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=1,
            label='Your favourite animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(self.field_choices),
            required=True)
        self.normal_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=2,
            label='Your other favourite animal',
            field_type='singleline',
            required=True)
        self.positive_number_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=3,
            label='How old are you',
            field_type='positive_number',
            required=True)

    def test_survey_options_512_limit_overriden(self):
        field_choices = [
            'My favourite animal is a dog, because they bark',
            'My favourite animal is a cat, because they meuow',
            'My favourite animal is a bird, because they fly',
            'My favourite animal is a lion, because that roar',
            'My favourite animal is a hamster, because they have tiny legs',
            'My favourite animal is a tiger, because they have stripes',
            'My favourite animal is a frog, because they go crickit',
            'My favourite animal is a fish, because they have nice eyes',
            'My favourite animal is a chicken, because they cannot fly',
            'My favourite animal is a duck, because they keep it down',
            'My favourite animal is a wolf, because they howl',
            'My favourite animal is a chamelion, because they fit in',
        ]
        choice_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=1,
            label='Your favourite animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(field_choices),
            required=True)
        self.assertTrue(len(choice_field.choices) > 512)

    def test_choices_updated_from_streamfield_on_save(self):
        self.assertEqual(','.join(self.field_choices),
                         self.choice_field.choices)

        new_choices = ['this', 'is', 'new']
        self.choice_field.skip_logic = skip_logic_data(new_choices)
        self.choice_field.save()

        self.assertEqual(','.join(new_choices), self.choice_field.choices)

    def test_normal_field_is_not_skippable(self):
        self.assertFalse(self.normal_field.has_skipping)

    def test_positive_number_field_is_not_skippable(self):
        self.assertFalse(self.positive_number_field.has_skipping)

    def test_only_next_doesnt_skip(self):
        self.assertFalse(self.choice_field.has_skipping)

    def test_other_logic_does_skip(self):
        self.choice_field.skip_logic = skip_logic_data(['choice'], ['end'])
        self.choice_field.save()
        self.assertTrue(self.choice_field.has_skipping)
Esempio n. 12
0
class TestSkipLogicEveryPage(TestCase, MoloTestCaseMixin):
    def setUp(self):
        self.mk_main()
        self.survey = MoloSurveyPage(
            title='Test Survey',
            slug='test-survey',
        )
        self.another_survey = MoloSurveyPage(
            title='Another Test Survey',
            slug='another-test-survey',
        )
        self.section_index.add_child(instance=self.survey)
        self.survey.save_revision().publish()
        self.section_index.add_child(instance=self.another_survey)
        self.another_survey.save_revision().publish()
        field_choices = ['next', 'end']
        self.fourth_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=4,
            label='A random animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(
                field_choices,
                field_choices,
            ),
            required=True
        )
        self.first_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=1,
            label='Your other favourite animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(
                field_choices + ['question', 'survey'],
                field_choices + ['question', 'survey'],
                question=self.fourth_field,
                survey=self.another_survey,
            ),
            required=True
        )
        self.second_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=2,
            label='Your favourite animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(
                field_choices,
                field_choices,
            ),
            required=True
        )
        self.third_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=3,
            label='Your least favourite animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(
                field_choices,
                field_choices,
            ),
            required=True
        )
        self.paginator = SkipLogicPaginator(self.survey.get_form_fields())

    def test_initialises_correctly(self):
        self.assertEqual(self.paginator.page_breaks, [0, 1, 2, 3, 4])
        self.assertEqual(self.paginator.num_pages, 4)

    def test_first_question_skip_to_last(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            {self.first_field.clean_name: 'question'},
        )
        self.assertEqual(paginator.previous_page, 1)
        self.assertEqual(paginator.next_page, 4)
        page = paginator.page(paginator.next_page)
        self.assertEqual(page.object_list, [self.fourth_field])
        self.assertEqual(page.number, 4)

    def test_first_question_skip_to_next(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            {self.first_field.clean_name: 'next'},
        )
        self.assertEqual(paginator.previous_page, 1)
        self.assertEqual(paginator.next_page, 2)
        page = paginator.page(paginator.next_page)
        self.assertEqual(page.object_list, [self.second_field])
        self.assertEqual(page.number, 2)

    def test_first_question_skip_to_survey(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            {self.first_field.clean_name: 'survey'},
        )
        self.assertEqual(paginator.previous_page, 1)
        page = paginator.page(1)
        self.assertFalse(page.has_next())
Esempio n. 13
0
class TestSkipLogicPaginator(TestCase, MoloTestCaseMixin):
    def setUp(self):
        self.mk_main()
        self.survey = MoloSurveyPage(
            title='Test Survey',
            slug='test-survey',
        )
        self.section_index.add_child(instance=self.survey)
        self.survey.save_revision().publish()
        self.first_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=1,
            label='Your other favourite animal',
            field_type='singleline',
            required=True
        )
        self.fourth_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=4,
            label='A random animal',
            field_type='singleline',
            required=True
        )
        field_choices = ['next', 'end', 'question']
        self.second_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=2,
            label='Your favourite animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(
                field_choices,
                field_choices,
                question=self.fourth_field,
            ),
            required=True
        )
        self.third_field = MoloSurveyFormField.objects.create(
            page=self.survey,
            sort_order=3,
            label='Your least favourite animal',
            field_type='dropdown',
            skip_logic=skip_logic_data(
                field_choices,
                field_choices,
                question=self.fourth_field,
            ),
            required=True
        )
        self.paginator = SkipLogicPaginator(self.survey.get_form_fields())

    def test_correct_num_pages(self):
        self.assertEqual(self.paginator.num_pages, 3)

    def test_page_breaks_correct(self):
        self.assertEqual(self.paginator.page_breaks, [0, 2, 3, 4])

    def test_first_page_correct(self):
        page = self.paginator.page(1)
        self.assertEqual(
            page.object_list,
            [self.first_field, self.second_field],
        )
        self.assertTrue(page.has_next())

    def test_second_page_correct(self):
        page = self.paginator.page(2)
        self.assertEqual(page.object_list, [self.third_field])
        self.assertTrue(page.has_next())

    def test_last_page_correct(self):
        last_page = self.paginator.page(3)
        self.assertEqual(last_page.object_list, [self.fourth_field])
        self.assertFalse(last_page.has_next())

    def test_is_end_if_skip_logic(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            {self.second_field.clean_name: 'end'}
        )
        first_page = paginator.page(1)
        self.assertFalse(first_page.has_next())

    def test_skip_question_if_skip_logic(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            {self.second_field.clean_name: 'question'}
        )
        page = paginator.page(1)
        next_page_number = page.next_page_number()
        self.assertEqual(next_page_number, 3)
        second_page = paginator.page(next_page_number)
        self.assertEqual(second_page.object_list, [self.fourth_field])

    def test_first_question_skip_to_next(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            {self.second_field.clean_name: 'next'},
        )
        self.assertEqual(paginator.previous_page, 1)
        self.assertEqual(paginator.next_page, 2)
        page = paginator.page(paginator.next_page)
        self.assertEqual(page.object_list, [self.third_field])
        self.assertEqual(page.number, 2)

    def test_previous_page_if_skip_a_page(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            {
                self.first_field.clean_name: 'python',
                self.second_field.clean_name: 'question',
            }
        )
        page = paginator.page(1)
        next_page_number = page.next_page_number()
        self.assertEqual(next_page_number, 3)
        second_page = paginator.page(next_page_number)
        previous_page_number = second_page.previous_page_number()
        self.assertEqual(previous_page_number, 1)
        self.assertEqual(
            paginator.page(previous_page_number).object_list,
            [self.first_field, self.second_field],
        )

    def test_question_progression_index(self):
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            {
                self.first_field.clean_name: 'python',
                self.second_field.clean_name: 'question',
            }
        )
        self.assertEqual(paginator.previous_page, 1)
        self.assertEqual(paginator.last_question_index, 1)
        self.assertEqual(paginator.next_page, 3)
        self.assertEqual(paginator.next_question_index, 3)

    def test_no_data_index(self):
        paginator = SkipLogicPaginator(self.survey.get_form_fields())
        self.assertEqual(paginator.previous_page, 1)
        self.assertEqual(paginator.next_page, 1)
        self.assertEqual(paginator.next_question_index, 0)

    def test_no_data_index_with_checkbox(self):
        self.first_field.field_type = 'checkbox'
        self.first_field.skip_logic = skip_logic_data(
            ['', ''],
            ['next', 'end'],
        )
        self.first_field.save()
        paginator = SkipLogicPaginator(
            self.survey.get_form_fields(),
            data={'csrf': 'dummy'},
        )
        self.assertEqual(paginator.previous_page, 1)
        self.assertEqual(paginator.last_question_index, 0)
        self.assertEqual(paginator.next_page, 2)
        self.assertEqual(paginator.next_question_index, 1)

    def test_single_question_quiz_with_skip_logic_pages_correctly(self):
        self.first_field.delete()
        self.third_field.delete()
        self.fourth_field.delete()
        paginator = SkipLogicPaginator(self.survey.get_form_fields())
        self.assertEqual(paginator.num_pages, 1)