def test_repeating_skipped_group(self):
        schema = load_schema_from_params('test', 'navigation_confirmation')

        routing_path = [
            Location('property-details', 0, 'insurance-type'),
            Location('property-details', 0, 'insurance-address'),
            Location('property-details', 0, 'property-interstitial'),
            Location('house-details', 0, 'house-type'),
            Location('multiple-questions-group', 0, 'household-composition'),
            Location('repeating-group', 0, 'repeating-block-1'),
            Location('repeating-group', 0, 'repeating-block-2'),
            Location('extra-cover', 0, 'extra-cover-block'),
            Location('extra-cover', 0, 'extra-cover-interstitial'),
            Location('payment-details', 0, 'credit-card'),
            Location('payment-details', 0, 'expiry-date'),
            Location('payment-details', 0, 'security-code'),
            Location('payment-details', 0, 'security-code-interstitial'),
            Location('extra-cover-items-group', 0, 'extra-cover-items'),
            Location('confirmation-group', 0, 'confirmation'),
        ]

        progress = Completeness(
            schema, AnswerStore(), [], routing_path, metadata={})
        progress_value = progress.get_state_for_group('repeating-group')
        self.assertEqual(Completeness.SKIPPED, progress_value)
    def test_only_question_blocks_counted_for_completeness(self):
        schema_data = {
            'sections': [{
                'id': 'section_1',
                'groups': [{
                    'id': 'group_1',
                    'blocks': [
                        {
                            'id': 'question-block',
                            'type': 'Question',
                            'questions': [{
                                'id': 'question',
                                'title': 'foo',
                                'type': 'general',
                                'answers': []
                            }]
                        },
                        {
                            'id': 'interstitial-block',
                            'type': 'Interstitial',
                            'questions': [{
                                'id': 'interstitial-question',
                                'title': 'bar',
                                'type': 'general',
                                'answers': []
                            }]
                        }
                    ]
                }]
            }]
        }
        schema = QuestionnaireSchema(schema_data)

        completed_blocks = [
            Location('group_1', 0, 'question-block'),
        ]

        routing_path = [
            Location('group_1', 0, 'question-block'),
            Location('group_1', 0, 'interstitial-block'),
        ]

        progress = Completeness(
            schema, AnswerStore(), completed_blocks, routing_path, metadata={})
        self.assertEqual(Completeness.COMPLETED, progress.get_state_for_group('group_1'))
        self.assertEqual(Completeness.COMPLETED, progress.get_state_for_section('section_1'))
        self.assertTrue(progress.all_sections_complete())
    def test_confirmation_questions_checked_for_completeness(self):
        schema_data = {
            'sections': [{
                'id': 'section_1',
                'groups': [{
                    'id': 'group_1',
                    'blocks': [
                        {
                            'id': 'question-block',
                            'type': 'Question',
                            'questions': [{
                                'id': 'question',
                                'title': 'foo',
                                'type': 'general',
                                'answers': []
                            }]
                        },
                        {
                            'id': 'confirm-question-block',
                            'type': 'ConfirmationQuestion',
                            'questions': [{
                                'id': 'confirm-question',
                                'title': 'bar',
                                'type': 'general',
                                'answers': []
                            }]
                        }
                    ]
                }]
            }]
        }
        schema = QuestionnaireSchema(schema_data)

        completed_blocks = [
            Location('group_1', 0, 'question-block'),
        ]

        routing_path = [
            Location('group_1', 0, 'question-block'),
            Location('group_1', 0, 'confirm-question-block'),
        ]

        progress = Completeness(
            schema, AnswerStore(), completed_blocks, routing_path, metadata={})
        self.assertEqual(Completeness.STARTED, progress.get_state_for_group('group_1'))
        self.assertEqual(Completeness.STARTED, progress.get_state_for_section('section_1'))
    def test_skipped_group(self):
        schema = load_schema_from_params('test', 'navigation')

        completed_blocks = [
            Location('property-details', 0, 'insurance-type'),
            Location('property-details', 0, 'insurance-address'),
            Location('property-details', 0, 'property-interstitial'),
            Location('house-details', 0, 'house-type'),
            Location('multiple-questions-group', 0, 'household-composition'),
            Location('repeating-group', 0, 'repeating-block-1'),
            Location('repeating-group', 0, 'repeating-block-2'),
            Location('extra-cover', 0, 'extra-cover-block'),
            Location('extra-cover', 0, 'extra-cover-interstitial'),
            Location('payment-details', 0, 'credit-card'),
            Location('payment-details', 0, 'expiry-date'),
            Location('payment-details', 0, 'security-code'),
            Location('payment-details', 0, 'security-code-interstitial'),
            Location('extra-cover-items-group', 0, 'extra-cover-items'),
        ]

        routing_path = [
            Location('property-details', 0, 'insurance-type'),
            Location('property-details', 0, 'insurance-address'),
            Location('property-details', 0, 'property-interstitial'),
            Location('house-details', 0, 'house-type'),
            Location('multiple-questions-group', 0, 'household-composition'),
            Location('repeating-group', 0, 'repeating-block-1'),
            Location('repeating-group', 0, 'repeating-block-2'),
            Location('payment-details', 0, 'credit-card'),
            Location('payment-details', 0, 'expiry-date'),
            Location('payment-details', 0, 'security-code'),
            Location('payment-details', 0, 'security-code-interstitial'),
            Location('extra-cover', 0, 'extra-cover-block'),
            Location('extra-cover', 0, 'extra-cover-interstitial'),
            Location('extra-cover-items-group', 0, 'extra-cover-items'),
            Location('summary-group', 0, 'summary'),
        ]

        progress = Completeness(
            schema, AnswerStore(), completed_blocks, routing_path, metadata={})
        with patch('app.questionnaire.path_finder.evaluate_skip_conditions', return_value=True):
            progress_value = progress.get_state_for_group('payment-details')
        self.assertEqual(Completeness.SKIPPED, progress_value)