Пример #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'}