'Verify that groups descriptions are rendered correctly.'

@ddt.unpack
@ddt.data({'descriptions': ('desc1', 'desc2'), 'descriptions_html': '<description>desc1</description><description>desc2</description>'}, {'descriptions': (), 'descriptions_html': ''})
def test_descriptions(self, descriptions, descriptions_html):

    xml = '\n                                <problem>\n                                                <optionresponse>\n                                                                <label>group    label</label>\n                                                                {descriptions_html}\n                                                                <optioninput    options="(\'yellow\',\'blue\',\'green\')"    correct="blue"    label="first    label"/>\n                                                                <optioninput    options="(\'yellow\',\'blue\',\'green\')"    correct="green"    label="second    label"/>\n                                                </optionresponse>\n                                </problem>\n                                '.format(descriptions_html=descriptions_html)
    problem = self.capa_problem(xml)
    problem_html = etree.XML(problem.get_html())
    multi_inputs_group = problem_html.xpath('//div[@class="multi-inputs-group"]')[0]
    description_ids = multi_inputs_group.attrib.get('aria-describedby', '').split()
    self.assertEqual(len(description_ids), len(descriptions))
    for (index, description_id) in enumerate(description_ids):
        description_element = multi_inputs_group.xpath('//p[@id="{}"]'.format(description_id))
        self.assertEqual(len(description_element), 1)
        self.assertEqual(description_element[0].text, descriptions[index])
