Example #1
0
    def test_is_repeating_answer_type_checkbox(self):
        survey_json = {
            'sections': [{
                'id':
                'section1',
                'groups': [{
                    'id':
                    'question-group',
                    'blocks': [{
                        'id':
                        'question-block',
                        'type':
                        'Question',
                        'questions': [{
                            'id':
                            'question',
                            'type':
                            'General',
                            'answers': [{
                                'id': 'frequency-answer',
                                'options': [{
                                    'value': 'Weekly'
                                }],
                                'type': 'Checkbox'
                            }]
                        }]
                    }]
                }]
            }]
        }

        schema = QuestionnaireSchema(survey_json)

        self.assertTrue(schema.is_repeating_answer_type('frequency-answer'))
Example #2
0
    def test_is_repeating_answer_type_general_answer(self):
        survey_json = {
            'sections': [{
                'id':
                'section1',
                'groups': [{
                    'id':
                    'question-group',
                    'blocks': [{
                        'id':
                        'question-block',
                        'type':
                        'Question',
                        'questions': [{
                            'id': 'question',
                            'type': 'General',
                            'answers': [{
                                'id': 'first-name'
                            }]
                        }]
                    }]
                }]
            }]
        }

        schema = QuestionnaireSchema(survey_json)

        self.assertFalse(schema.is_repeating_answer_type('first-name'))
def get_test_schema():
    test_json = _load_schema_file('test_schema_context.json', DEFAULT_LANGUAGE_CODE)
    schema = QuestionnaireSchema(test_json, DEFAULT_LANGUAGE_CODE)

    schema.is_repeating_answer_type = MagicMock(return_value=False)
    schema.answer_is_in_repeating_group = MagicMock(return_value=False)
    return schema
    def test_is_repeating_answer_type_checkbox(self):
        survey_json = {
            'sections': [{
                'id': 'section1',
                'groups': [{
                    'id': 'question-group',
                    'blocks': [
                        {
                            'id': 'question-block',
                            'type': 'Question',
                            'questions': [{
                                'id': 'question',
                                'type': 'General',
                                'answers': [{
                                    'id': 'frequency-answer',
                                    'options': [{
                                        'value': 'Weekly'
                                    }],
                                    'type': 'Checkbox'
                                }]
                            }]
                        }
                    ]
                }]
            }]
        }

        # STANDARD CHECKBOX
        schema = QuestionnaireSchema(survey_json)

        self.assertTrue(schema.is_repeating_answer_type('frequency-answer'))

        # MUTUALLY EXCLUSIVE CHECKBOX
        survey_json['sections'][0]['groups'][0]['blocks'][0]['questions'][0]['answers'][0]['type'] = 'MutuallyExclusiveCheckbox'
        schema = QuestionnaireSchema(survey_json)

        self.assertTrue(schema.is_repeating_answer_type('frequency-answer'))