def test_field_to_dict_select(self):
     form = FruitForm(letter='b')
     form.validate()
     assert ke_forms.field_to_dict(form.letter) == \
         {'data': 'b', 'errors': []}
     assert ke_forms.field_to_dict(form.letter2) == \
         {'data': None, 'errors': ['This field is required.']}
Exemple #2
0
 def test_field_to_dict_select(self):
     form = FruitForm(letter='b')
     form.validate()
     assert ke_forms.field_to_dict(form.letter) == \
         {'data': 'b', 'errors': [], 'label': 'Letter', 'required': False}
     assert ke_forms.field_to_dict(form.letter2) == {
         'data': None,
         'errors': ['This field is required.'],
         'label': 'Letter2',
         'required': True
     }
Exemple #3
0
 def test_field_to_dict_field(self):
     form = NumbersSubForm()
     form.validate()
     assert ke_forms.field_to_dict(form.number) == {
         'data': None,
         'errors': ['This field is required.'],
         'label': 'Number',
         'required': True
     }
 def test_field_to_dict_form_fieldlist(self):
     data = {
         'numbers-0-number': '123',
         'numbers-1-color': 'blue',
     }
     form = NumbersForm(MultiDict(data))
     form.validate()
     expected = [
         {'number': {'data': '123', 'errors': []}, 'color': {'data': '', 'errors': []}},
         {'number': {'data': '', 'errors': ['This field is required.']},
             'color': {'data': 'blue', 'errors': []}},
     ]
     assert ke_forms.field_to_dict(form.numbers) == expected
Exemple #5
0
 def test_field_to_dict_fieldlist(self):
     form = NumbersForm()
     form.validate()
     expected = [
         {
             'data': None,
             'errors': [],
             'label': 'Number',
             'required': False,
         },
         {
             'data': None,
             'errors': [],
             'label': 'Number',
             'required': False,
         }
     ]
     assert ke_forms.field_to_dict(form.numbers2) == expected
 def test_field_to_dict_fieldlist(self):
     form = NumbersForm()
     form.validate()
     expected = [{'data': None, 'errors': []}, {'data': None, 'errors': []}]
     assert ke_forms.field_to_dict(form.numbers2) == expected