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