Exemple #1
0
    def test_required(self):
        f = DateUnitField(required=False)
        self.assertEqual(None, f.clean(None))

        f = DateUnitField()
        with self.assertRaises(ValidationError):
            f.clean(None)
Exemple #2
0
 def test_empty_value_validators(self):
     # By default django skips run_validators methods, if value is in empty_values
     # It's not correct for REST, as empty value is not equal to None value now
     f = DateUnitField(validators=[TestErrorValidator(0)])
     with self.assertRaises(ValidationError):
         f.clean('day')
Exemple #3
0
 def test_initial(self):
     f = DateUnitField(required=False, initial='day')
     self.assertEqual('day', f.clean(None))
Exemple #4
0
 def test_invalid(self):
     f = DateUnitField()
     with self.assertRaises(ValidationError):
         f.clean('something')
Exemple #5
0
 def test_week(self):
     f = DateUnitField()
     self.assertEqual('week', f.clean('week'))
Exemple #6
0
 def test_hour(self):
     f = DateUnitField()
     self.assertEqual('hour', f.clean('hour'))
Exemple #7
0
 def test_day(self):
     f = DateUnitField()
     self.assertEqual('day', f.clean('day'))