def test_size_in_field(self):
     validator = MaxSizeValidator('checkFileMaxSize')
     or_image_size = self.settings.image_size
     self.settings.image_size = 0
     self.assertEqual(
         float(10),
         self.helper_view.get_maxsize(validator,
                                      **{'field': base.get_image_field()}))
     self.settings.image_size = or_image_size
示例#2
0
 def test_size_in_field(self):
     validator = MaxSizeValidator('checkFileMaxSize')
     or_image_size = self.settings.image_size
     self.settings.image_size = 0
     self.assertEqual(float(10),
                      get_maxsize(validator,
                                  self.settings,
                                  **{'field': base.get_image_field()}
                                  )
                      )
     self.settings.image_size = or_image_size
示例#3
0
 def test_size_from_registry_type_setting(self):
     # new in version 1.3: type/field specific settings
     validator = MaxSizeValidator('checkFileMaxSize', maxsize=50.0)
     self.settings.types_settings += (TypesSettings(u'News Item', u'image', 7), )
     self.assertEqual(float(7),
                      get_maxsize(validator,
                                  self.settings,
                                  **{'maxsize': 15.0 ,
                                     'field': base.get_image_field(),
                                     'instance': base.PFObject()}
                                  )
                               )
     self.settings.types_settings = ()
 def test_size_from_registry_type_setting(self):
     # new in version 1.3: type/field specific settings
     validator = MaxSizeValidator('checkFileMaxSize', maxsize=50.0)
     new_value = (TypesSettings(u'News Item', u'image', 7), )
     self.settings.types_settings += new_value
     self.assertEqual(
         float(7),
         self.helper_view.get_maxsize(
             validator, **{
                 'maxsize': 15.0,
                 'field': base.get_image_field(),
                 'instance': base.PFObject()
             }))
     self.settings.types_settings = ()
 def test_size_from_registry(self):
     # original validator for file and image read maxsize from
     # zconf.ATFile.max_file_size at the end we have a number
     # so we pass maxsize=N.
     # By default in the registry we have 30MB for file and 10MB for images
     # and calling the validator with all the possible values, validation
     # should be done with user values
     validator = MaxSizeValidator('checkFileMaxSize', maxsize=50.0)
     self.assertEqual(float(30), self.helper_view.get_maxsize(
         validator,
         **{'maxsize': 15.0,
            'field': base.get_file_field(),
            'instance': base.PFObject()}
         )
     )
     self.assertEqual(float(10), self.helper_view.get_maxsize(
         validator,
         **{'maxsize': 15.0,
            'field': base.get_image_field(),
            'instance': base.PFObject()}
         )
     )
 def test_size_from_registry(self):
     # original validator for file and image read maxsize from
     # zconf.ATFile.max_file_size at the end we have a number
     # so we pass maxsize=N.
     # By default in the registry we have 30MB for file and 10MB for images
     # and calling the validator with all the possible values, validation
     # should be done with user values
     validator = MaxSizeValidator('checkFileMaxSize', maxsize=50.0)
     self.assertEqual(
         float(30),
         self.helper_view.get_maxsize(
             validator, **{
                 'maxsize': 15.0,
                 'field': base.get_file_field(),
                 'instance': base.PFObject()
             }))
     self.assertEqual(
         float(10),
         self.helper_view.get_maxsize(
             validator, **{
                 'maxsize': 15.0,
                 'field': base.get_image_field(),
                 'instance': base.PFObject()
             }))
 def test_size_from_registry(self):
     # original validator for file and image read maxsize from
     # zconf.ATFile.max_file_size at the end we have a number
     # so we pass maxsize=N.
     # By default in the registry we have 30Mb for file and 10Mb for images
     # and calling the validator with all the possible values, validation
     # should be done with user values
     validator = MaxSizeValidator("checkFileMaxSize", maxsize=50.0)
     self.assertEqual(
         float(30),
         get_maxsize(
             validator,
             self.settings,
             **{"maxsize": 15.0, "field": base.get_file_field(), "instance": base.PFObject()}
         ),
     )
     self.assertEqual(
         float(10),
         get_maxsize(
             validator,
             self.settings,
             **{"maxsize": 15.0, "field": base.get_image_field(), "instance": base.PFObject()}
         ),
     )