def test_basic(self): filename = namers.default( thumbnailer=FakeThumbnailer(), prepared_options=['100x100', 'q80', 'crop', 'upscale'], source_filename='source.jpg', thumbnail_extension='jpg', ) self.assertEqual(filename, 'source.jpg.100x100_q80_crop_upscale.jpg')
def test_basedir_opts(self): filename = namers.default( thumbnailer=FakeThumbnailer(basedir='%(opts)s'), prepared_options=['100x100', 'q80', 'crop', 'upscale'], source_filename='source.gif', thumbnail_extension='png', ) self.assertEqual(filename, 'source.gif.png')
def test_basedir_opts(self): filename = namers.default( thumbnailer=FakeThumbnailer(basedir="%(opts)s"), prepared_options=["100x100", "q80", "crop", "upscale"], source_filename="source.gif", thumbnail_extension="png", ) self.assertEqual(filename, "source.gif.png")
def test_basic(self): filename = namers.default( thumbnailer=FakeThumbnailer(), prepared_options=["100x100", "q80", "crop", "upscale"], source_filename="source.jpg", thumbnail_extension="jpg", ) self.assertEqual(filename, "source.jpg.100x100_q80_crop_upscale.jpg")
def default(thumbnailer, prepared_options, source_filename, thumbnail_extension, **kwargs): fmt = kwargs.get('thumbnail_options', {}).get('format') if fmt: thumbnail_extension = fmt return namers.default(thumbnailer, prepared_options, source_filename, thumbnail_extension, **kwargs)