Ejemplo n.º 1
0
 def test_render_checkbox_multiple_values(self):
     field = fields.Checkbox(name='test',
                             label='My Checkbox Group',
                             values=(('Test', 1), ('Testing', 2),
                                     ('Testing Again', 3)),
                             value=(1, 2))
     assert str(
         field
     ) == '<label for="test_0">Test<input checked="checked" id="test_0" name="test" type="checkbox" value="1" /></label><label for="test_1">Testing<input checked="checked" id="test_1" name="test" type="checkbox" value="2" /></label><label for="test_2">Testing Again<input id="test_2" name="test" type="checkbox" value="3" /></label>'
Ejemplo n.º 2
0
 def test_render_checkbox_attrs(self):
     field = fields.Checkbox(name='test',
                             label='My Checkbox Group',
                             values=(('Test', 1), ('Testing', 2)))
     single_field_value = fields.Checkbox(name='test',
                                          label='My Checkbox',
                                          values=1)
     checked_field = fields.Checkbox(name='test',
                                     label='My Checkbox',
                                     values=1,
                                     value=1)
     assert str(
         field
     ) == '<label for="test_0">Test<input id="test_0" name="test" type="checkbox" value="1" /></label><label for="test_1">Testing<input id="test_1" name="test" type="checkbox" value="2" /></label>'
     assert str(
         single_field_value
     ) == '<label for="test">My Checkbox<input id="test" name="test" type="checkbox" value="1" /></label>'
     assert str(
         checked_field
     ) == '<label for="test">My Checkbox<input checked="checked" id="test" name="test" type="checkbox" value="1" /></label>'
Ejemplo n.º 3
0
 def test_label_position(self):
     field = fields.Checkbox(label_position='right')
     assert field.label_position == 'right'
Ejemplo n.º 4
0
 def test_create(self):
     field = fields.Checkbox(name='test')
     assert field.value is None
     assert field.name == 'test'