Ejemplo n.º 1
0
    def test_process_path_dots_in_path(self):
        path = '/path.to/image.jpg.width-300_height-200.png'
        modifier = ImageModifier(path, self.base_config)

        filename = modifier.source_filename

        self.assertEquals(filename, '/path.to/image.jpg')

        path = '/path.to/another.nice/image.jpg.width-300_height-200.png'
        modifier = ImageModifier(path, self.base_config)

        filename = modifier.source_filename

        self.assertEquals(filename, '/path.to/another.nice/image.jpg')
Ejemplo n.º 2
0
    def test_process_path_change_ext(self):
        path = '/path/to/image.jpg.to.gif'
        modifier = ImageModifier(path, self.base_config)

        filename = modifier.source_filename
        params = modifier._params

        self.assertEquals(filename, '/path/to/image.jpg')
        self.assertEquals(params['type'], 'gif')
Ejemplo n.º 3
0
    def test_process_path_unusual_nochange_filenames(self):
        test_filenames = (
            '/path/to/image.jpg..png',
            '/path/to/image.jpg.png',
            '/path/to/image.jpg._.png',
        )

        for t in test_filenames:
            modifier = ImageModifier(t, self.base_config)
            filename = modifier.source_filename
            self.assertEquals(filename, t)
Ejemplo n.º 4
0
    def test_process_path_with_param(self):
        path = '/path/to/image.jpg.width-300.png'
        modifier = ImageModifier(path, self.base_config)

        filename = modifier.source_filename
        params = modifier._params

        self.assertEquals(filename, '/path/to/image.jpg')
        self.assertEquals(params['type'], 'png')
        self.assertEquals(params['width'], '300')
        self.assertEquals(len(params), 2)
Ejemplo n.º 5
0
    def test_process_path_with_unusual_params(self):
        path = '/path/to/image.jpg.width-300_height-200_crop-400,40,1000,1000.png'
        modifier = ImageModifier(path, self.base_config)

        filename = modifier.source_filename
        params = modifier._params

        self.assertEquals(filename, '/path/to/image.jpg')
        self.assertEquals(params['type'], 'png')
        self.assertEquals(params['width'], '300')
        self.assertEquals(params['height'], '200')
        self.assertEquals(params['crop'], '400,40,1000,1000')
        self.assertEquals(len(params), 4)
Ejemplo n.º 6
0
    def test_process_path_invalid_ext(self):
        path = '/path/to/image.ext'

        with self.assertRaises(ResizerFormatException):
            ImageModifier(path, self.base_config)