# Path: testsuite/cases/base.py
# def rpartial(func, *args, **keywords):
#     """
#     right partial — same as functools.partial, but pass function args first
#     """
#     def newfunc(*fargs, **fkeywords):
#         newkeywords = keywords.copy()
#         newkeywords.update(fkeywords)
#         return func(*(fargs + args), **newkeywords)
#     newfunc.func = func
#     newfunc.args = args
#     newfunc.keywords = keywords
#     return newfunc
# 
# def root(*chunks):
#     return os.path.abspath(os.path.join(
#         os.path.dirname(__file__), '..', *chunks))
# 
# class FullCycleBaseCase(BaseTestCase):
#     def handle_args(self, level, name, filename, filetype):
#         self.level = level
#         self.name = name
#         self.filename = filename
#         self.filetype = filetype
# 
#     def create_test_data(self):
#         return ()
# 
#     def readable_args(self):
#         return [self.name]
# 
# Path: testsuite/cases/vips.py
# class VipsTestCase(BaseTestCase):
#     def resize(cls, im, *args, **kwargs):


from .base import rpartial, root, FullCycleBaseCase
from .vips import Image, VipsTestCase


class FullCycleCase(FullCycleBaseCase, VipsTestCase):
    def runner(self):
        im = Image.new_from_file(root('resources', self.filename),
                                 autorotate=(self.level>0))
        if self.level > 1:
            im = self.resize(im, 0.4, kernel='cubic')

        if self.level > 2:
            im = im.gaussblur(4, min_ampl=0.07)

        im.write_to_buffer('.'+self.filetype, Q=85)
        # im.write_to_file('../_out.{}.vips.png'.format(self.level))


cases = [

# Path: testsuite/cases/base.py
# def rpartial(func, *args, **keywords):
#     """
#     right partial — same as functools.partial, but pass function args first
#     """
#     def newfunc(*fargs, **fkeywords):
#         newkeywords = keywords.copy()
#         newkeywords.update(fkeywords)
#         return func(*(fargs + args), **newkeywords)
#     newfunc.func = func
#     newfunc.args = args
#     newfunc.keywords = keywords
#     return newfunc
# 
# def root(*chunks):
#     return os.path.abspath(os.path.join(
#         os.path.dirname(__file__), '..', *chunks))
# 
# class FullCycleBaseCase(BaseTestCase):
#     def handle_args(self, level, name, filename, filetype):
#         self.level = level
#         self.name = name
#         self.filename = filename
#         self.filetype = filetype
# 
#     def create_test_data(self):
#         return ()
# 
#     def readable_args(self):
#         return [self.name]
# 
# Path: testsuite/cases/vips.py
# class VipsTestCase(BaseTestCase):
#     def resize(cls, im, *args, **kwargs):


# Path: testsuite/cases/vips_full_cycle.py
from .base import rpartial, root, FullCycleBaseCase
from .vips import Image, VipsTestCase



class FullCycleCase(FullCycleBaseCase, VipsTestCase):
    def runner(self):
        im = Image.new_from_file(root('resources', self.filename),
                                 autorotate=(self.level>0))
        if self.level > 1:
            im = self.resize(im, 0.4, kernel='cubic')

        if self.level > 2:
            im = im.gaussblur(4, min_ampl=0.07)

        im.write_to_buffer('.'+self.filetype, Q=85)
        # im.write_to_file('../_out.{}.vips.png'.format(self.level))


cases = [

    rpartial(FullCycleCase, 0, 'Load+save', 'pineapple.jpeg', 'JPEG'),