Commit f565393c by E. Kolpakov

Fixed exception when parsing XML with comments.

Added newline at the end of file

Fixed exception when parsing XML with comments
parent 612274ab
...@@ -99,6 +99,8 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin): ...@@ -99,6 +99,8 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
@classmethod @classmethod
def add_node_as_child(cls, block, xml_child, child_id): def add_node_as_child(cls, block, xml_child, child_id):
# Instantiate child # Instantiate child
if not isinstance(xml_child.tag, str):
return
child_class = cls.get_class_by_element(xml_child.tag) child_class = cls.get_class_by_element(xml_child.tag)
child = child_class(block) child = child_class(block)
child.name = u'{}_{}'.format(block.name, child_id) child.name = u'{}_{}'.format(block.name, child_id)
......
...@@ -141,3 +141,34 @@ class MCQBlockTest(MentoringBaseTest): ...@@ -141,3 +141,34 @@ class MCQBlockTest(MentoringBaseTest):
self.assertEqual(progress.text, '') self.assertEqual(progress.text, '')
self.assertTrue(progress.find_elements_by_css_selector('img')) self.assertTrue(progress.find_elements_by_css_selector('img'))
def test_mcq_with_comments(self):
mentoring = self.go_to_page('MCQ With Comments 1')
mcq = mentoring.find_element_by_css_selector('fieldset.choices')
messages = mentoring.find_element_by_css_selector('.messages')
progress = mentoring.find_element_by_css_selector('.progress > .indicator')
self.assertEqual(messages.text, '')
self.assertFalse(messages.find_elements_by_xpath('./*'))
self.assertEqual(progress.text, '')
self.assertFalse(progress.find_elements_by_xpath('./*'))
mcq_legend = mcq.find_element_by_css_selector('legend')
self.assertEqual(mcq_legend.text, 'Do you like this MCQ?')
mcq_choices = mcq.find_elements_by_css_selector('.choices .choice label')
self.assertEqual(len(mcq_choices), 3)
self.assertEqual(mcq_choices[0].text, 'Its elegance')
self.assertEqual(mcq_choices[1].text, 'Its beauty')
self.assertEqual(mcq_choices[2].text, "Its gracefulness")
self.assertEqual(mcq_choices[3].text, "Its bugs")
mcq_choices_input = [
mcq_choices[0].find_element_by_css_selector('input'),
mcq_choices[1].find_element_by_css_selector('input'),
mcq_choices[2].find_element_by_css_selector('input'),
]
self.assertEqual(mcq_choices_input[0].get_attribute('value'), 'elegance')
self.assertEqual(mcq_choices_input[1].get_attribute('value'), 'beauty')
self.assertEqual(mcq_choices_input[2].get_attribute('value'), 'gracefulness')
self.assertEqual(mcq_choices_input[3].get_attribute('value'), 'bugs')
<vertical>
<mentoring url_name="mentoring-87043a1f-f14a-4813-b89f-3e051939a7ee" display_name="MRQ Exercise 7" weight="1">
<title>MRQ With Resizable popups</title>
<mrq name="mrq_1_1_7" type="choices">
<question>What do you like in this MRQ?</question>
<choice value="elegance">Its elegance</choice>
<choice value="beauty">Its beauty</choice>
<choice value="gracefulness">Its gracefulness</choice>
<choice value="bugs">Its bugs</choice>
<tip require="gracefulness" width ="200" height = "200">This MRQ is indeed very graceful</tip>
<tip require="elegance" width ="600" height = "800">This is something everyone has to like about this MRQ</tip>
<tip require="beauty" width ="400" height = "600">This is something everyone has to like about beauty</tip>
<tip reject="bugs" width = "100" height = "200">Nah, there isn\'t any!</tip>
<!--<message type="on-submit">Thank you for answering!</message> -->
</mrq>
<message type="completed">
<html><p>Congratulations!</p></html>
</message>
<message type="incomplete">
<html><p>Still some work to do...</p></html>
</message>
</mentoring>
</vertical>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment