Commit 1a843c2d by Victor Shnayder

Remove non-working TrueFalse functionality from choicegroup, combine tests with…

Remove non-working TrueFalse functionality from choicegroup, combine tests with radiogroup and checkboxgroup
parent 1d499045
......@@ -202,16 +202,11 @@ class ChoiceGroup(InputTypeBase):
def __init__(self, system, xml, state):
super(ChoiceGroup, self).__init__(system, xml, state)
# suffix is '' or [] to change the way the input is handled in --as a scalar or vector
# value. (VS: would be nice to make to this less hackish).
if self.tag == 'choicegroup':
self.suffix = ''
if self.xml.get('type') == "MultipleChoice":
self.element_type = "radio"
elif self.xml.get('type') == "TrueFalse":
# Huh? Why TrueFalse->checkbox? Each input can be true / false separately?
self.element_type = "checkbox"
else:
self.element_type = "radio"
self.element_type = "radio"
elif self.tag == 'radiogroup':
self.element_type = "radio"
self.suffix = '[]'
......
......@@ -48,50 +48,8 @@ class OptionInputTest(unittest.TestCase):
class ChoiceGroupTest(unittest.TestCase):
'''
Test choice groups.
Test choice groups, radio groups, and checkbox groups
'''
def test_mult_choice(self):
xml_template = """
<choicegroup {0}>
<choice correct="false" name="foil1"><text>This is foil One.</text></choice>
<choice correct="false" name="foil2"><text>This is foil Two.</text></choice>
<choice correct="true" name="foil3">This is foil Three.</choice>
</choicegroup>
"""
def check_type(type_str, expected_input_type):
print "checking for type_str='{0}'".format(type_str)
xml_str = xml_template.format(type_str)
element = etree.fromstring(xml_str)
state = {'value': 'foil3',
'id': 'sky_input',
'status': 'answered'}
option_input = lookup_tag('choicegroup')(test_system, element, state)
context = option_input._get_render_context()
expected = {'id': 'sky_input',
'value': 'foil3',
'state': 'answered',
'input_type': expected_input_type,
'choices': [('foil1', '<text>This is foil One.</text>'),
('foil2', '<text>This is foil Two.</text>'),
('foil3', 'This is foil Three.'),],
'name_array_suffix': '', # what is this for??
}
self.assertEqual(context, expected)
check_type('', 'radio')
check_type('type=""', 'radio')
check_type('type="MultipleChoice"', 'radio')
check_type('type="TrueFalse"', 'checkbox')
# fallback.
check_type('type="StrangeUnknown"', 'radio')
def check_group(self, tag, expected_input_type, expected_suffix):
xml_str = """
......@@ -124,6 +82,9 @@ class ChoiceGroupTest(unittest.TestCase):
self.assertEqual(context, expected)
def test_choicegroup(self):
self.check_group('choicegroup', 'radio', '')
def test_radiogroup(self):
self.check_group('radiogroup', 'radio', '[]')
......
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