示例#1
0
 def test_to_internal_value(self):
     instance = fields.SmallIntegerField()
     self.assertEqual(instance.to_internal_value(1), 1)
示例#2
0
 def test_init_default(self):
     instance = fields.SmallIntegerField()
     self.assertEqual(instance.min_value, -instance.MAX_SMALL_INTEGER - 1)
     self.assertEqual(instance.max_value, instance.MAX_SMALL_INTEGER)
示例#3
0
    def test_to_internal_value_raises_validate_exception(self):
        instance = fields.SmallIntegerField()

        with self.assertRaises(ValidationError):
            instance.to_internal_value('object')
示例#4
0
 def test_to_to_representation(self):
     instance = fields.SmallIntegerField()
     self.assertEqual(instance.to_representation('1'), 1)
示例#5
0
    def test_to_internal_value_raises_max_string_length_exception(self):
        instance = fields.SmallIntegerField()

        with self.assertRaises(ValidationError):
            data = 'value' * 250
            instance.to_internal_value(data)