def test_question_followup_get_data(self): section = ContentSection(slug='section', name=TemplateField('Section one'), prefill=False, editable=False, edit_questions=False, questions=[ Question({ 'id': 'q1', 'followup': { 'q2': [False] }, 'type': 'boolean' }), Question({ 'id': 'q2', 'type': 'boolean' }) ]).filter({}) assert section.get_data(MultiDict([('q1', 'false')])) == {'q1': False} assert section.get_data(MultiDict([('q1', 'true')])) == { 'q1': True, 'q2': None } assert section.get_data(MultiDict([('q1', 'false'), ('q2', 'true')])) == { 'q1': False, 'q2': True } assert section.get_data(MultiDict([('q1', 'true'), ('q2', 'true')])) == { 'q1': True, 'q2': None }
def test_question_followup_get_data(self): section = ContentSection( slug='section', name=TemplateField('Section one'), prefill=False, editable=False, edit_questions=False, questions=[Question({'id': 'q1', 'followup': {'q2': [False]}, 'type': 'boolean'}), Question({'id': 'q2', 'type': 'boolean'})] ).filter({}) assert section.get_data(MultiDict([('q1', 'false')])) == {'q1': False} assert section.get_data(MultiDict([('q1', 'true')])) == {'q1': True, 'q2': None} assert section.get_data( MultiDict([('q1', 'false'), ('q2', 'true')]) ) == {'q1': False, 'q2': True} assert section.get_data( MultiDict([('q1', 'true'), ('q2', 'true')]) ) == {'q1': True, 'q2': None}
def test_question_followup_get_data(self, filter_inplace_allowed, get_data_arg, expected_retval): section = ContentSection( slug='section', name=TemplateField('Section one'), prefill=False, editable=False, edit_questions=False, questions=[Question({'id': 'q1', 'followup': {'q2': [False]}, 'type': 'boolean'}), Question({'id': 'q2', 'type': 'boolean'})] ).filter({}, inplace_allowed=filter_inplace_allowed) assert section.get_data(get_data_arg) == expected_retval