Beispiel #1
0
 def test_get_field_schema_integer(self):
     field = forms.IntegerField(label='label', help_text='help')
     self.assertEqual(
         {
             'type': 'integer',
             'title': 'label',
             'description': 'help',
         },
         djangoutil.get_field_schema('name', field),
     )
Beispiel #2
0
 def test_get_field_schema_datetime(self):
     field = forms.DateTimeField(label='label', help_text='help')
     self.assertEqual(
         {
             'type': 'string',
             'format': 'date-time',
             'title': 'label',
             'description': 'help',
         },
         djangoutil.get_field_schema('name', field),
     )
Beispiel #3
0
 def test_get_field_schema_choice(self):
     field = forms.ChoiceField(
         label='label', help_text='help', choices=['A', 'B', 'C'])
     self.assertEqual(
         {
             'type': 'string',
             'title': 'label',
             'description': 'help',
             'enum': ['A', 'B', 'C']
         },
         djangoutil.get_field_schema('name', field),
     )
Beispiel #4
0
 def test_get_field_schema_multiple_choice_checkbox_widget(self):
     field = forms.MultipleChoiceField(
         label='label',
         help_text='help',
         choices=['A', 'B', 'C'],
         widget=forms.CheckboxSelectMultiple(),
     )
     self.assertEqual(
         {
             'type': 'array',
             'title': 'label',
             'description': 'help',
             'items': {
                 'type': 'string',
                 'enum': ['A', 'B', 'C'],
             }
         },
         djangoutil.get_field_schema('name', field),
     )