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})
def test_simple_url_field(self): prop = field_to_property(fields.Url('endpoint')) self.assertEqual(prop, {'type': 'string'})
def test_url_field_with_required(self): prop = field_to_property(fields.Url('endpoint', required=True)) self.assertEqual(prop, {'type': 'string', 'required': True})
def test_simple_datetime_field(self): prop = field_to_property(fields.DateTime) self.assertEqual(prop, {'type': 'string', 'format': 'date-time'})
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'})
def test_arbitrary_field_with_required(self): prop = field_to_property(fields.Arbitrary(required=True)) self.assertEqual(prop, {'type': 'number', 'required': True})
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})
def test_boolean_field_with_readonly(self): prop = field_to_property(fields.Boolean(readonly=True)) self.assertEqual(prop, {'type': 'boolean', 'readOnly': True})
def test_boolean_field_with_default(self): prop = field_to_property(fields.Boolean(default=True)) self.assertEqual(prop, {'type': 'boolean', 'default': True})
def test_boolean_field_with_title(self): prop = field_to_property(fields.Boolean(title='A title')) self.assertEqual(prop, {'type': 'boolean', 'title': 'A title'})
def test_boolean_field_with_required(self): prop = field_to_property(fields.Boolean(required=True)) self.assertEqual(prop, {'type': 'boolean', 'required': True})
def test_boolean_field_with_description(self): prop = field_to_property(fields.Boolean(description='A description')) self.assertEqual(prop, { 'type': 'boolean', 'description': 'A description' })
def test_simple_boolean_field(self): prop = field_to_property(fields.Boolean) self.assertEqual(prop, {'type': 'boolean'})
def test_integer_field_with_default(self): prop = field_to_property(fields.Integer(default=42)) self.assertEqual(prop, {'type': 'integer', 'default': 42})
def test_arbitrary_field_with_description(self): prop = field_to_property(fields.Arbitrary(description='A description')) self.assertEqual(prop, { 'type': 'number', 'description': 'A description' })
def test_simple_fixed_field(self): prop = field_to_property(fields.Fixed) self.assertEqual(prop, {'type': 'number'})
def test_arbitrary_field_with_title(self): prop = field_to_property(fields.Arbitrary(title='A title')) self.assertEqual(prop, {'type': 'number', 'title': 'A title'})
def test_fixed_field_with_description(self): prop = field_to_property(fields.Fixed(description='A description')) self.assertEqual(prop, { 'type': 'number', 'description': 'A description' })
def test_arbitrary_field_with_readonly(self): prop = field_to_property(fields.Arbitrary(readonly=True)) self.assertEqual(prop, {'type': 'number', 'readOnly': True})
def test_fixed_field_with_title(self): prop = field_to_property(fields.Fixed(title='A title')) self.assertEqual(prop, {'type': 'number', 'title': 'A title'})
def test_arbitrary_field_with_default(self): prop = field_to_property(fields.Arbitrary(default=0.5)) self.assertEqual(prop, {'type': 'number', 'default': 0.5})
def test_fixed_field_with_required(self): prop = field_to_property(fields.Fixed(required=True)) self.assertEqual(prop, {'type': 'number', 'required': True})
def test_simple_formatted_string_field(self): prop = field_to_property(fields.FormattedString('Hello {name}')) self.assertEqual(prop, {'type': 'string'})
def test_fixed_field_with_readonly(self): prop = field_to_property(fields.Fixed(readonly=True)) self.assertEqual(prop, {'type': 'number', 'readOnly': True})
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})
def test_fixed_field_with_default(self): prop = field_to_property(fields.Fixed(default=0.5)) self.assertEqual(prop, {'type': 'number', 'default': 0.5})
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'})
def test_simple_arbitrary_field(self): prop = field_to_property(fields.Arbitrary) self.assertEqual(prop, {'type': 'number'})
def test_custom_field(self): class Custom(fields.Raw): pass prop = field_to_property(Custom) self.assertEqual(prop, {'type': 'object'})
def test_integer_field_with_readonly(self): prop = field_to_property(fields.Integer(readonly=True)) self.assertEqual(prop, {'type': 'integer', 'readOnly': True})