def test_no_groups(self): schema = load_schema_from_params('test', 'navigation_completeness') schema.json['sections'][0]['groups'] = [] progress = Completeness(schema, AnswerStore(), [], [], metadata={}) progress_value = progress.get_state_for_section('coffee-section') self.assertEqual(Completeness.NOT_STARTED, progress_value)
def test_get_state_for_section(self): """ This is a bad test that is really only for coverage. The test navigation schema should be changed to include a situation where all groups in a section are 'invalid' AND 'skipped' """ with patch('app.questionnaire.completeness.Completeness.get_state_for_group', side_effect=['SKIPPED', 'INVALID']): completeness = Completeness([], [], [], [], []) self.assertEqual(completeness.get_state_for_section({'groups': [1, 1]}), 'SKIPPED')
def test_not_started_section(self): schema = load_schema_from_params('test', 'navigation_completeness') routing_path = [ Location('coffee-group', 0, 'coffee'), ] progress = Completeness(schema, AnswerStore(), [], routing_path, metadata={}) progress_value = progress.get_state_for_section('coffee-section') self.assertEqual(Completeness.NOT_STARTED, 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_completed_section(self): schema = load_schema_from_params('test', 'navigation_completeness') completed_blocks = [ Location('coffee-group', 0, 'coffee'), Location('coffee-group', 0, 'response-yes'), ] routing_path = [ Location('coffee-group', 0, 'coffee'), Location('coffee-group', 0, 'response-yes'), ] progress = Completeness( schema, AnswerStore(), completed_blocks, routing_path, metadata={}) progress_value = progress.get_state_for_section('coffee-section') self.assertEqual(Completeness.COMPLETED, progress_value)
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_repeating_skipped_section(self): schema = load_schema_from_params('test', 'navigation_confirmation') 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('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(), completed_blocks, routing_path, metadata={}) progress_value = progress.get_state_for_section( 'household-full-names-section') self.assertEqual(Completeness.SKIPPED, progress_value)