示例#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})
示例#2
0
 def test_simple_url_field(self):
     prop = field_to_property(fields.Url('endpoint'))
     self.assertEqual(prop, {'type': 'string'})
示例#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})
示例#4
0
 def test_simple_datetime_field(self):
     prop = field_to_property(fields.DateTime)
     self.assertEqual(prop, {'type': 'string', 'format': 'date-time'})
示例#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'})
示例#6
0
 def test_arbitrary_field_with_required(self):
     prop = field_to_property(fields.Arbitrary(required=True))
     self.assertEqual(prop, {'type': 'number', 'required': True})
示例#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})
示例#8
0
 def test_boolean_field_with_readonly(self):
     prop = field_to_property(fields.Boolean(readonly=True))
     self.assertEqual(prop, {'type': 'boolean', 'readOnly': True})
示例#9
0
 def test_boolean_field_with_default(self):
     prop = field_to_property(fields.Boolean(default=True))
     self.assertEqual(prop, {'type': 'boolean', 'default': True})
示例#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'})
示例#11
0
 def test_boolean_field_with_required(self):
     prop = field_to_property(fields.Boolean(required=True))
     self.assertEqual(prop, {'type': 'boolean', 'required': True})
示例#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'
     })
示例#13
0
 def test_simple_boolean_field(self):
     prop = field_to_property(fields.Boolean)
     self.assertEqual(prop, {'type': 'boolean'})
示例#14
0
 def test_integer_field_with_default(self):
     prop = field_to_property(fields.Integer(default=42))
     self.assertEqual(prop, {'type': 'integer', 'default': 42})
示例#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'
     })
示例#16
0
 def test_simple_fixed_field(self):
     prop = field_to_property(fields.Fixed)
     self.assertEqual(prop, {'type': 'number'})
示例#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'})
示例#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'
     })
示例#19
0
 def test_arbitrary_field_with_readonly(self):
     prop = field_to_property(fields.Arbitrary(readonly=True))
     self.assertEqual(prop, {'type': 'number', 'readOnly': True})
示例#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'})
示例#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})
示例#22
0
 def test_fixed_field_with_required(self):
     prop = field_to_property(fields.Fixed(required=True))
     self.assertEqual(prop, {'type': 'number', 'required': True})
示例#23
0
 def test_simple_formatted_string_field(self):
     prop = field_to_property(fields.FormattedString('Hello {name}'))
     self.assertEqual(prop, {'type': 'string'})
示例#24
0
 def test_fixed_field_with_readonly(self):
     prop = field_to_property(fields.Fixed(readonly=True))
     self.assertEqual(prop, {'type': 'number', 'readOnly': True})
示例#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})
示例#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})
示例#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'})
示例#28
0
 def test_simple_arbitrary_field(self):
     prop = field_to_property(fields.Arbitrary)
     self.assertEqual(prop, {'type': 'number'})
示例#29
0
    def test_custom_field(self):
        class Custom(fields.Raw):
            pass

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