Exemplo n.º 1
0
 def test_integer_field_with_min_max(self):
     prop = field_to_property(fields.Integer(min=0, max=5))
     self.assertEqual(prop, {'type': 'integer', 'minimum': 0, 'maximum': 5})
Exemplo n.º 2
0
 def test_simple_url_field(self):
     prop = field_to_property(fields.Url('endpoint'))
     self.assertEqual(prop, {'type': 'string'})
Exemplo n.º 3
0
 def test_url_field_with_required(self):
     prop = field_to_property(fields.Url('endpoint', required=True))
     self.assertEqual(prop, {'type': 'string', 'required': True})
Exemplo n.º 4
0
 def test_simple_datetime_field(self):
     prop = field_to_property(fields.DateTime)
     self.assertEqual(prop, {'type': 'string', 'format': 'date-time'})
Exemplo n.º 5
0
 def test_formatted_field_with_title(self):
     prop = field_to_property(
         fields.FormattedString('Hello {name}', title='A title'))
     self.assertEqual(prop, {'type': 'string', 'title': 'A title'})
Exemplo n.º 6
0
 def test_arbitrary_field_with_required(self):
     prop = field_to_property(fields.Arbitrary(required=True))
     self.assertEqual(prop, {'type': 'number', 'required': True})
Exemplo n.º 7
0
 def test_arbitrary_field_with_min_max(self):
     prop = field_to_property(fields.Arbitrary(min=0, max=5))
     self.assertEqual(prop, {'type': 'number', 'minimum': 0, 'maximum': 5})
Exemplo n.º 8
0
 def test_boolean_field_with_readonly(self):
     prop = field_to_property(fields.Boolean(readonly=True))
     self.assertEqual(prop, {'type': 'boolean', 'readOnly': True})
Exemplo n.º 9
0
 def test_boolean_field_with_default(self):
     prop = field_to_property(fields.Boolean(default=True))
     self.assertEqual(prop, {'type': 'boolean', 'default': True})
Exemplo n.º 10
0
 def test_boolean_field_with_title(self):
     prop = field_to_property(fields.Boolean(title='A title'))
     self.assertEqual(prop, {'type': 'boolean', 'title': 'A title'})
Exemplo n.º 11
0
 def test_boolean_field_with_required(self):
     prop = field_to_property(fields.Boolean(required=True))
     self.assertEqual(prop, {'type': 'boolean', 'required': True})
Exemplo n.º 12
0
 def test_boolean_field_with_description(self):
     prop = field_to_property(fields.Boolean(description='A description'))
     self.assertEqual(prop, {
         'type': 'boolean',
         'description': 'A description'
     })
Exemplo n.º 13
0
 def test_simple_boolean_field(self):
     prop = field_to_property(fields.Boolean)
     self.assertEqual(prop, {'type': 'boolean'})
Exemplo n.º 14
0
 def test_integer_field_with_default(self):
     prop = field_to_property(fields.Integer(default=42))
     self.assertEqual(prop, {'type': 'integer', 'default': 42})
Exemplo n.º 15
0
 def test_arbitrary_field_with_description(self):
     prop = field_to_property(fields.Arbitrary(description='A description'))
     self.assertEqual(prop, {
         'type': 'number',
         'description': 'A description'
     })
Exemplo n.º 16
0
 def test_simple_fixed_field(self):
     prop = field_to_property(fields.Fixed)
     self.assertEqual(prop, {'type': 'number'})
Exemplo n.º 17
0
 def test_arbitrary_field_with_title(self):
     prop = field_to_property(fields.Arbitrary(title='A title'))
     self.assertEqual(prop, {'type': 'number', 'title': 'A title'})
Exemplo n.º 18
0
 def test_fixed_field_with_description(self):
     prop = field_to_property(fields.Fixed(description='A description'))
     self.assertEqual(prop, {
         'type': 'number',
         'description': 'A description'
     })
Exemplo n.º 19
0
 def test_arbitrary_field_with_readonly(self):
     prop = field_to_property(fields.Arbitrary(readonly=True))
     self.assertEqual(prop, {'type': 'number', 'readOnly': True})
Exemplo n.º 20
0
 def test_fixed_field_with_title(self):
     prop = field_to_property(fields.Fixed(title='A title'))
     self.assertEqual(prop, {'type': 'number', 'title': 'A title'})
Exemplo n.º 21
0
 def test_arbitrary_field_with_default(self):
     prop = field_to_property(fields.Arbitrary(default=0.5))
     self.assertEqual(prop, {'type': 'number', 'default': 0.5})
Exemplo n.º 22
0
 def test_fixed_field_with_required(self):
     prop = field_to_property(fields.Fixed(required=True))
     self.assertEqual(prop, {'type': 'number', 'required': True})
Exemplo n.º 23
0
 def test_simple_formatted_string_field(self):
     prop = field_to_property(fields.FormattedString('Hello {name}'))
     self.assertEqual(prop, {'type': 'string'})
Exemplo n.º 24
0
 def test_fixed_field_with_readonly(self):
     prop = field_to_property(fields.Fixed(readonly=True))
     self.assertEqual(prop, {'type': 'number', 'readOnly': True})
Exemplo n.º 25
0
 def test_formatted_string_field_with_readonly(self):
     prop = field_to_property(
         fields.FormattedString('Hello {name}', readonly=True))
     self.assertEqual(prop, {'type': 'string', 'readOnly': True})
Exemplo n.º 26
0
 def test_fixed_field_with_default(self):
     prop = field_to_property(fields.Fixed(default=0.5))
     self.assertEqual(prop, {'type': 'number', 'default': 0.5})
Exemplo n.º 27
0
 def test_url_field_with_title(self):
     prop = field_to_property(fields.Url('endpoint', title='A title'))
     self.assertEqual(prop, {'type': 'string', 'title': 'A title'})
Exemplo n.º 28
0
 def test_simple_arbitrary_field(self):
     prop = field_to_property(fields.Arbitrary)
     self.assertEqual(prop, {'type': 'number'})
Exemplo n.º 29
0
    def test_custom_field(self):
        class Custom(fields.Raw):
            pass

        prop = field_to_property(Custom)
        self.assertEqual(prop, {'type': 'object'})
Exemplo n.º 30
0
 def test_integer_field_with_readonly(self):
     prop = field_to_property(fields.Integer(readonly=True))
     self.assertEqual(prop, {'type': 'integer', 'readOnly': True})