Пример #1
0
    def get_filter(self, filter_name, params_string="", config_context=None):
        config = Config(
            FILTERS=[filter_name],
            LOADER="thumbor.loaders.file_loader",
            FILE_LOADER_ROOT_PATH=join(dirname(realpath(__file__)), "fixtures",
                                       "filters"),
        )
        importer = Importer(config)
        importer.import_modules()

        req = RequestParameters()

        srv = ServerParameters(8888, "localhost", "./tests/test.conf", None,
                               "DEBUG", None)
        srv._security_key = "MY_SECURE_KEY"

        context = Context(config=config, importer=importer, server=srv)
        context.request = req
        context.request.engine = context.modules.engine
        context.request_handler = mock.MagicMock(request=mock.MagicMock(
            protocol="http",
            host="localhost:8888",
        ))

        if config_context is not None:
            config_context(context)

        self.context = context

        fltr = importer.filters[0]
        fltr.pre_compile()

        context.transformer = Transformer(context)

        return fltr(params_string, context=context)
Пример #2
0
 def get_server(self):
     srv = ServerParameters(8888, "localhost", "./tests/test.conf", None,
                            "DEBUG", None)
     srv._security_key = "MY_SECURE_KEY"
     return srv
 def get_server(self):
     srv = ServerParameters(8888, "localhost", './tests/test.conf', None,
                            'DEBUG', None)
     srv._security_key = 'MY_SECURE_KEY'
     return srv