def test_checkbox_field(self):
checkbox_json = {
"guidance": "",
"id": "opening-crawler-answer",
"label": "",
"mandatory": False,
"options": [
{
"label": "Luke Skywalker",
"value": "Luke Skywalker"
},
{
"label": "Han Solo",
"value": "Han Solo"
},
{
"label": "The Emperor",
"value": "The Emperor"
},
{
"label": "R2D2",
"value": "R2D2"
},
{
"label": "Senator Amidala",
"value": "Senator Amidala"
},
{
"label": "Yoda",
"value": "Yoda"
}
],
"q_code": "7",
"type": "Checkbox"
}
unbound_field = get_field(checkbox_json, checkbox_json['label'], error_messages, self.answer_store)
expected_choices = [(option['label'], option['value']) for option in checkbox_json['options']]
self.assertTrue(unbound_field.field_class == SelectMultipleField)
self.assertEquals(unbound_field.kwargs['label'], checkbox_json['label'])
self.assertEquals(unbound_field.kwargs['description'], checkbox_json['guidance'])
self.assertEquals(unbound_field.kwargs['choices'], expected_choices)
评论列表
文章目录