Exemple #1
0
    def test_to_internal_value_raises_validation_error_for_too_long_str(self):
        instance = fields.FloatField(max_value=10)

        with self.assertRaises(ValidationError):
            instance.to_internal_value('test' * 255)
Exemple #2
0
 def test_to_representation(self):
     instance = fields.FloatField()
     self.assertEqual(instance.to_representation(5), 5.0)
Exemple #3
0
    def test_to_internal_value_raises_validation_error(self):
        instance = fields.FloatField()

        with self.assertRaises(ValidationError):
            instance.to_internal_value(None)
Exemple #4
0
 def test_to_internal_value(self):
     instance = fields.FloatField()
     self.assertEqual(instance.to_internal_value(5), 5)
Exemple #5
0
    def test_run_validation_with_defined_max_value(self):
        instance = fields.FloatField(max_value=10.0)

        with self.assertRaises(ValidationError):
            instance.run_validation(11.0)
Exemple #6
0
 def test_run_validation_without_borders(self):
     instance = fields.FloatField()
     self.assertEqual(instance.run_validation(5.0), 5.0)
Exemple #7
0
 def test_init_default(self):
     instance = fields.FloatField()
     self.assertIsNone(instance.min_value)
     self.assertIsNone(instance.max_value)