Exemple #1
0
 def test_add_validators_aspect_ratio(self):
     vc = VimageConfig({'myapp.models.MyModel.img': {
         'ASPECT_RATIO': 1,
     }})
     vc.add_validators()
     self.assertEqual(len(self.img.validators), 1)
     self.assertIn('ValidationRuleAspectRatio.generate_validator',
                   str(self.img.validators[0]))
Exemple #2
0
 def test_add_validators_format(self):
     vc = VimageConfig({'myapp.models.MyModel.img': {
         'FORMAT': 'png',
     }})
     vc.add_validators()
     self.assertEqual(len(self.img.validators), 1)
     self.assertIn('ValidationRuleFormat.generate_validator',
                   str(self.img.validators[0]))
Exemple #3
0
 def test_add_validators_size(self):
     vc = VimageConfig({'myapp.models.MyModel.img': {
         'SIZE': 1000,
     }})
     vc.add_validators()
     self.assertEqual(len(self.img.validators), 1)
     self.assertIn('ValidationRuleSize.generate_validator',
                   str(self.img.validators[0]))
Exemple #4
0
 def test_add_validators_dimensions(self):
     vc = VimageConfig(
         {'myapp.models.MyModel.img': {
             'DIMENSIONS': (1000, 1000),
         }})
     vc.add_validators()
     self.assertEqual(len(self.img.validators), 1)
     self.assertIn('ValidationRuleDimensions.generate_validator',
                   str(self.img.validators[0]))
Exemple #5
0
 def test_add_validators_multiple(self):
     vc = VimageConfig({
         'myapp.models.MyModel.img': {
             'SIZE': 1000,
             'DIMENSIONS': (1000, 1000),
             'FORMAT': 'jpeg',
         }
     })
     vc.add_validators()
     self.assertEqual(len(self.img.validators), 3)