How to use the masonite.testsuite.generate_wsgi function in masonite

To help you get started, we’ve selected a few masonite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MasoniteFramework / masonite / masonite / testing / TestCase.py View on Github external
def create_container(self):
        container = App()
        from config import application
        from config import providers

        container.bind('WSGI', generate_wsgi())
        container.bind('Application', application)
        container.bind('Container', container)

        container.bind('ProvidersConfig', providers)
        container.bind('Providers', [])
        container.bind('WSGIProviders', [])

        """Bind all service providers
        Let's register everything into the Service Container. Once everything is
        in the container we can run through all the boot methods. For reasons
        some providers don't need to execute with every request and should
        only run once when the server is started. Providers will be ran
        once if the wsgi attribute on a provider is False.
        """

        for provider in container.make('ProvidersConfig').PROVIDERS:
github MasoniteFramework / masonite / masonite / testing / TestCase.py View on Github external
def run_container(self, wsgi_values={}):
        wsgi = generate_wsgi()
        wsgi.update(wsgi_values)
        self.container.bind('Environ', wsgi)
        self.container.make('Request')._test_user = self.acting_user
        self.container.make('Request').load_app(self.container).load_environ(wsgi)
        if self._with_subdomains:
            self.container.make('Request').activate_subdomains()

        if self.headers:
            self.container.make('Request').header(self.headers)

        if self.route_middleware is not False:
            self.container.bind('RouteMiddleware', self.route_middleware)

        if self.http_middleware is not False:
            self.container.bind('HttpMiddleware', self.http_middleware)
github MasoniteFramework / masonite / tests / middleware / test_maintenance_mode_middleware.py View on Github external
def setUp(self):
        self.request = Request(generate_wsgi())
        self.middleware = MaintenanceModeMiddleware(self.request)
        down_path = os.path.join(application.BASE_DIRECTORY, 'bootstrap/down')
        down = os.path.exists(down_path)
        if down:
            os.remove(down_path)
github MasoniteFramework / masonite / tests / middleware / test_secure_headers_middleware.py View on Github external
def setUp(self):
        self.request = Request(generate_wsgi())
        self.middleware = SecureHeadersMiddleware(self.request)
        self.app = TestSuite().create_container().container
        self.app.bind('Request', self.request.load_app(self.app))
        self.request = self.app.make('Request')
github MasoniteFramework / masonite / masonite / testing / TestCase.py View on Github external
def create_container(self):
        container = App()
        from config import application
        from config import providers

        container.bind('WSGI', generate_wsgi())
        container.bind('Application', application)
        container.bind('Container', container)

        container.bind('ProvidersConfig', providers)
        container.bind('Providers', [])
        container.bind('WSGIProviders', [])

        """Bind all service providers
        Let's register everything into the Service Container. Once everything is
        in the container we can run through all the boot methods. For reasons
        some providers don't need to execute with every request and should
        only run once when the server is started. Providers will be ran
        once if the wsgi attribute on a provider is False.
        """

        for provider in container.make('ProvidersConfig').PROVIDERS:
github MasoniteFramework / masonite / masonite / testing / TestCase.py View on Github external
def run_container(self, wsgi_values={}):
        wsgi = generate_wsgi()
        wsgi.update(wsgi_values)
        self.container.bind('Environ', wsgi)
        self.container.make('Request')._test_user = self.acting_user
        self.container.make('Request').load_app(self.container).load_environ(wsgi)
        if self._with_subdomains:
            self.container.make('Request').activate_subdomains()

        if self.headers:
            self.container.make('Request').header(self.headers)

        if self.route_middleware is not False:
            self.container.bind('RouteMiddleware', self.route_middleware)

        if self.http_middleware is not False:
            self.container.bind('HttpMiddleware', self.http_middleware)
github MasoniteFramework / masonite / masonite / testing / MockRoute.py View on Github external
def hasSession(self, key):
        wsgi = generate_wsgi()
        wsgi['PATH_INFO'] = self.route.route_url
        wsgi['RAW_URI'] = self.route.route_url
        self.container = self._run_container(wsgi).container
        return self.container.make('Session').has(key)