How to use the masonite.testsuite.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 / tests / core / test_app.py View on Github external
from masonite.app import App
from masonite.request import Request
from masonite.testsuite.TestSuite import generate_wsgi
import unittest

REQUEST = Request({}).load_environ(generate_wsgi())


class MockMail:

    def __init__(self, request: Request):
        self.request = request


class TestApp(unittest.TestCase):

    def setUp(self):
        self.app = App()

    def test_app_binds(self):
        self.app.bind('test1', object)
        self.app.bind('test2', object)
github MasoniteFramework / masonite / tests / core / test_service_provider.py View on Github external
def test_can_call_container_with_annotations_from_variable(self):
        request = Request(generate_wsgi())

        self.app.bind('Request', request)
        self.app.bind('Get', Get().route('url', None))

        self.assertEqual(self.app.resolve(ContainerTest().testboot), self.app.make('Request'))
github MasoniteFramework / masonite / tests / core / test_requests.py View on Github external
from masonite.request import Request
from masonite.response import Response
from masonite.routes import Get, RouteGroup
from masonite.testsuite.TestSuite import generate_wsgi

from app.http.test_controllers.TestController import TestController
from config import application, providers

WEB_ROUTES = flatten_routes([
    Get('/test', 'Controller@show').name('test'),
    RouteGroup([
        Get('/account', 'Controller@show').name('a_account'),
    ], prefix='/a')
])

wsgi_request = generate_wsgi()


class TestRequest(unittest.TestCase):

    def setUp(self):
        self.app = App()
        self.request = Request(wsgi_request).key(
            'NCTpkICMlTXie5te9nJniMj9aVbPM6lsjeq5iDZ0dqY=').load_app(self.app)
        self.app.bind('Request', self.request)
        self.response = Response(self.app)
        self.app.simple(Response)

    def test_request_is_callable(self):
        """ Request should be callable """
        self.assertIsInstance(self.request, object)
github MasoniteFramework / masonite / tests / middleware / test_csrf_middleware.py View on Github external
def setUp(self):
        self.app = App()
        wsgi = generate_wsgi()
        self.request = Request(wsgi)
        self.route = Route().load_environ(wsgi)
        self.view = View(self.app)
        self.app.bind('Request', self.request)

        self.request = self.app.make('Request')
        self.app.bind('WebRoutes', [
            Get().route('/test/@route', None),
            Get().route('/test/10', None),
        ])
        self.request.container = self.app

        self.middleware = CsrfMiddleware(self.request, Csrf(self.request), self.view)
github MasoniteFramework / masonite / tests / core / test_providers.py View on Github external
def setUp(self):
        self.app = App(remember=False)
        self.app.bind('WSGI', object)

        self.app.bind('Application', application)
        self.app.bind('Providers', providers)
        self.app.bind('Environ', generate_wsgi())
github MasoniteFramework / masonite / tests / core / test_auth.py View on Github external
def setUp(self):
        super().setUp()
        self.container = App()
        self.app = self.container
        self.app.bind('Container', self.app)
        view = View(self.container)
        self.request = Request(generate_wsgi())
        self.request.key(application.KEY)
        self.app.bind('Request', self.request)
        # self.auth = Auth(self.request, MockUser())
        self.container.bind('View', view.render)
        self.container.bind('ViewClass', view)
        self.app.bind('Application', application)
        self.app.bind('Auth', Auth)
        self.app.bind('AuthConfig', auth)
        self.app.bind('AuthManager', AuthManager)
        self.app.bind('AuthCookieDriver', AuthCookieDriver)
        self.app.bind('AuthJwtDriver', AuthJwtDriver)

        self.auth = self.app.make('Auth', User)
        self.request.load_app(self.app)
github MasoniteFramework / masonite / tests / core / test_exception.py View on Github external
def setUp(self):
        self.app = App()
        self.app.bind('Application', ApplicationMock)
        self.app.bind('Environ', generate_wsgi())
        self.app.bind('WebRoutes', [])
        self.app.bind('View', View(self.app).render)
        self.app.bind('Request', Request(generate_wsgi()).load_app(self.app))
        self.app.bind('Response', Response(self.app))
        self.app.bind('StatusCode', None)
        self.app.bind('Storage', StorageMock)
        self.app.bind('ExceptionHandler', ExceptionHandler(self.app))
        self.app.bind('HookHandler', Hook(self.app))
        self.app.bind('Request', Request(generate_wsgi()).load_app(self.app))
        self.app.bind('ExceptionAttributeErrorHandler', MockExceptionHandler)
github MasoniteFramework / masonite / tests / core / test_request_routes.py View on Github external
def setUp(self):
        self.request = Request(generate_wsgi()).key(
            'NCTpkICMlTXie5te9nJniMj9aVbPM6lsjeq5iDZ0dqY=')

        self.request.activate_subdomains()
github MasoniteFramework / masonite / tests / providers / test_start_response.py View on Github external
def setup_method(self):
        self.app = App()
        self.provider = StartResponseProvider()

        self.app.bind('Response', None)
        self.app.bind('Request', Request(generate_wsgi()).load_app(self.app))

        self.provider.app = self.app
github MasoniteFramework / masonite / tests / core / test_exception.py View on Github external
def setUp(self):
        self.app = App()
        self.app.bind('Application', ApplicationMock)
        self.app.bind('Environ', generate_wsgi())
        self.app.bind('WebRoutes', [])
        self.app.bind('View', View(self.app).render)
        self.app.bind('Request', Request(generate_wsgi()).load_app(self.app))
        self.app.bind('Response', Response(self.app))
        self.app.bind('StatusCode', None)
        self.app.bind('Storage', StorageMock)
        self.app.bind('ExceptionHandler', ExceptionHandler(self.app))
        self.app.bind('HookHandler', Hook(self.app))
        self.app.bind('Request', Request(generate_wsgi()).load_app(self.app))
        self.app.bind('ExceptionAttributeErrorHandler', MockExceptionHandler)