示例#1
0
 def test_with_default_as_datetime(self):
     field = fields.Date(default=datetime(2014, 8, 25))
     assert field.__schema__ == {
         'type': 'string',
         'format': 'date',
         'default': '2014-08-25'
     }
示例#2
0
 def test_with_default(self):
     field = fields.Date(default='2014-08-25')
     assert field.__schema__ == {
         'type': 'string',
         'format': 'date',
         'default': '2014-08-25'
     }
     self.assert_field(field, None, '2014-08-25')
示例#3
0
 def test_unsupported_value_format(self):
     self.assert_field_raises(fields.Date(), 'xxx')
示例#4
0
 def test_value(self, value, expected):
     self.assert_field(fields.Date(), value, expected)
示例#5
0
 def test_max_exclusive(self):
     field = fields.Date(max='1984-06-07', exclusiveMax=True)
     assert 'maximum' in field.__schema__
     assert field.__schema__['maximum'] == '1984-06-07'
     assert 'exclusiveMaximum' in field.__schema__
     assert field.__schema__['exclusiveMaximum'] is True
示例#6
0
 def test_max_as_datetime(self):
     field = fields.Date(max=datetime(1984, 6, 7, 1, 2, 0))
     assert 'maximum' in field.__schema__
     assert field.__schema__['maximum'] == '1984-06-07'
     assert 'exclusiveMaximum' not in field.__schema__
示例#7
0
 def test_max(self):
     field = fields.Date(max='1984-06-07')
     assert 'maximum' in field.__schema__
     assert field.__schema__['maximum'] == '1984-06-07'
     assert 'exclusiveMaximum' not in field.__schema__
示例#8
0
 def test_min_exlusive(self):
     field = fields.Date(min='1984-06-07', exclusiveMin=True)
     assert 'minimum' in field.__schema__
     assert field.__schema__['minimum'] == '1984-06-07'
     assert 'exclusiveMinimum' in field.__schema__
     assert field.__schema__['exclusiveMinimum'] is True
示例#9
0
 def test_min_as_date(self):
     field = fields.Date(min=date(1984, 6, 7))
     assert 'minimum' in field.__schema__
     assert field.__schema__['minimum'] == '1984-06-07'
     assert 'exclusiveMinimum' not in field.__schema__
示例#10
0
 def test_defaults(self):
     field = fields.Date()
     assert not field.required
     assert field.__schema__ == {'type': 'string', 'format': 'date'}