Beispiel #1
0
 def test_not_required_false(self):
     f = RestBooleanField(required=False)
     self.assertEqual(False, f.clean('false'))
Beispiel #2
0
 def test_None(self):
     f = RestBooleanField()
     with self.assertRaises(ValidationError):
         f.clean(None)
Beispiel #3
0
 def test_not_required_1(self):
     f = RestBooleanField(required=False)
     self.assertEqual(True, f.clean('1'))
Beispiel #4
0
 def test_empty_string(self):
     f = RestBooleanField()
     self.assertEqual(False, f.clean(''))
Beispiel #5
0
 def test_not_empty_string(self):
     f = RestBooleanField()
     self.assertEqual(True, f.clean('some_text'))
Beispiel #6
0
 def test_false(self):
     f = RestBooleanField()
     self.assertEqual(False, f.clean('false'))
Beispiel #7
0
 def test_0(self):
     f = RestBooleanField()
     self.assertEqual(False, f.clean('0'))
Beispiel #8
0
 def test_true(self):
     f = RestBooleanField()
     self.assertEqual(True, f.clean('true'))
Beispiel #9
0
 def test_1(self):
     f = RestBooleanField()
     self.assertEqual(True, f.clean('1'))
Beispiel #10
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 = RestBooleanField(validators=[TestErrorValidator(0)])
     with self.assertRaises(ValidationError):
         f.clean('')
Beispiel #11
0
 def test_initial_false(self):
     f = RestBooleanField(required=False, initial=False)
     self.assertEqual(False, f.clean(None))
Beispiel #12
0
 def test_not_required_None(self):
     f = RestBooleanField(required=False)
     self.assertEqual(None, f.clean(None))
Beispiel #13
0
 def test_not_required_not_empty_string(self):
     f = RestBooleanField(required=False)
     self.assertEqual(True, f.clean('some_text'))
Beispiel #14
0
 def test_not_required_empty_string(self):
     f = RestBooleanField(required=False)
     self.assertEqual(False, f.clean(''))