def test_get_questions_unpacks_multiquestions(): section = ContentSection.create(section=get_section( questions=['checkboxes', 'boolean'], multiquestions=['checkboxes', 'boolean'] )) assert section.id == 'options' # should be a flat list with 4 entries questions = get_questions(section.questions) assert len(questions) == 4
def return_row_and_question(question_type, is_multiquestion=False): if is_multiquestion: section = ContentSection.create(section=get_section( multiquestions=[question_type], )) else: section = ContentSection.create(section=get_section( questions=[question_type], )) rows = return_rows_for_sections([section]) question = get_question(question_type, '0') assert len(rows) == 2 assert rows[0][0] == 'Options' assert rows[0][2] == question['question'] if is_multiquestion: assert rows[0][1] == 'Please indicate your preferred options' return rows[0], question
def test_get_questions_sets_multiquestion_names_and_hints(): section = ContentSection.create(section=get_section( multiquestions=['checkboxes', 'boolean'] )) assert section.id == 'options' # hint and name of multiquestion should be preserved in nested_questions for question in get_questions(section.questions): if question.get('id').startswith('multiquestion_'): assert question.get('parent').get('name') == 'Options' assert question.get('parent').get('hint') == 'Please indicate your preferred options'
def test_get_questions_sets_multiquestion_names_and_hints(): section = ContentSection.create(section=get_section( multiquestions=['checkboxes', 'boolean'] )) assert section.id == 'options' # hint and name of multiquestion should be preserved in nested_questions for question in get_questions(section.questions): if question.get('id').startswith('multiquestion_'): assert question.get('multiquestion_name') == 'Options' assert question.get('multiquestion_hint') == 'Please indicate your preferred options'
def return_row_and_question(question_type, is_multiquestion=False): if is_multiquestion: section = ContentSection.create(section=get_section( multiquestions=[question_type], )) else: section = ContentSection.create(section=get_section( questions=[question_type], )) rows = return_rows_for_sections([section]) question = get_question(question_type, '0') assert len(rows) == 2 if is_multiquestion: assert rows[0][0] == 'Section name / Options' else: assert rows[0][0] == 'Section name' assert rows[0][2] == question['question'] if is_multiquestion: assert rows[0][1] == 'Please indicate your preferred options' return rows[0], question