def test_versatile_image_field_rendition_key_sets_setting(self):
        """Ensure VERSATILEIMAGEFIELD_RENDITION_KEY_SETS setting validates."""
        with self.assertRaises(ImproperlyConfigured):
            get_rendition_key_set('does_not_exist')

        with self.assertRaises(InvalidSizeKeySet):
            get_rendition_key_set('invalid_set')

        with self.assertRaises(InvalidSizeKey):
            get_rendition_key_set('invalid_size_key')
    def test_versatile_image_field_rendition_key_sets_setting(self):
        """Ensure VERSATILEIMAGEFIELD_RENDITION_KEY_SETS setting validates."""
        with self.assertRaises(ImproperlyConfigured):
            get_rendition_key_set('does_not_exist')

        with self.assertRaises(InvalidSizeKeySet):
            get_rendition_key_set('invalid_set')

        with self.assertRaises(InvalidSizeKey):
            get_rendition_key_set('invalid_size_key')
Пример #3
0
    def test_VERSATILEIMAGEFIELD_RENDITION_KEY_SETS_setting(self):
        """
        Ensures VERSATILEIMAGEFIELD_RENDITION_KEY_SETS setting
        validates correctly
        """
        with self.assertRaises(ImproperlyConfigured):
            get_rendition_key_set('does_not_exist')

        with self.assertRaises(InvalidSizeKeySet):
            get_rendition_key_set('invalid_set')

        with self.assertRaises(InvalidSizeKey):
            get_rendition_key_set('invalid_size_key')
Пример #4
0
    def test_VERSATILEIMAGEFIELD_RENDITION_KEY_SETS_setting(self):
        """
        Ensures VERSATILEIMAGEFIELD_RENDITION_KEY_SETS setting
        validates correctly
        """
        with self.assertRaises(ImproperlyConfigured):
            get_rendition_key_set('does_not_exist')

        with self.assertRaises(InvalidSizeKeySet):
            get_rendition_key_set('invalid_set')

        with self.assertRaises(InvalidSizeKey):
            get_rendition_key_set('invalid_size_key')
Пример #5
0
 def __init__(self, sizes, *args, **kwargs):
     if isinstance(sizes, str):
         sizes = get_rendition_key_set(sizes)
     self.sizes = validate_versatileimagefield_sizekey_list(sizes)
     super(ImageLimitField, self).__init__(*args, **kwargs)
Пример #6
0
def build_image_types(request, image, key_set):
    data = []
    for key, value in build_versatileimagefield_url_set(
            image, get_rendition_key_set(key_set), request=request).items():
        data.append(RenditionType(name=key, url=value))
    return data