How to use the masonite.app.App 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_requests.py View on Github external
def test_redirect_compiles_url_with_multiple_parameters(self):
        app = App()
        app.bind('Request', self.request)
        request = app.make('Request').load_app(app)

        route = 'test/@id/@test'
        params = {
            'id': '1',
            'test': 'user',
        }
        self.assertEqual(request.compile_route_to_url(route, params), '/test/1/user')
github MasoniteFramework / masonite / tests / test_smtp_driver.py View on Github external
def test_mail_renders_template():
    app = App()

    app.bind('MailConfig', mail)
    app.bind('MailSmtpDriver', MailDriver)

    assert 'MasoniteTesting' in MailManager(app).driver('smtp').to(
        'idmann509@gmail.com').template('mail/welcome', {'to': 'MasoniteTesting'}).message_body
github MasoniteFramework / masonite / tests / core / test_requests.py View on Github external
def test_redirect_compiles_url_with_multiple_slashes(self):
        app = App()
        app.bind('Request', self.request)
        request = app.make('Request').load_app(app)

        route = 'test/url/here'

        self.assertEqual(request.compile_route_to_url(route), '/test/url/here')
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
github MasoniteFramework / masonite / tests / core / test_requests.py View on Github external
def test_request_redirection(self):
        app = App()
        app.bind('Request', self.request)
        app.bind('WebRoutes', [
            Get('/test/url', 'TestController@show').name('test.url'),
            Get('/test/url/@id', 'TestController@testing').name('test.id'),
            Get('/test/url/object', TestController.show).name('test.object')
        ])
        request = app.make('Request').load_app(app)

        self.assertEqual(request.redirect('/test/url/@id', {'id': 1}).redirect_url, '/test/url/1')
        request.redirect_url = None
        self.assertEqual(request.redirect(name='test.url').redirect_url, '/test/url')
        request.redirect_url = None
        self.assertEqual(request.redirect(name='test.id', params={'id': 1}).redirect_url, '/test/url/1')
        request.redirect_url = None
        self.assertEqual(request.redirect(controller='TestController@show').redirect_url, '/test/url')
        request.redirect_url = None
github MasoniteFramework / masonite / tests / core / test_mailgun_driver.py View on Github external
def setUp(self):
            self.app = App()
            self.app.bind('Container', self.app)

            self.app.bind('Test', object)
            self.app.bind('MailConfig', mail)
            self.app.bind('MailSmtpDriver', MailDriver)
            self.app.bind('MailMailgunDriver', Mailgun)
            viewClass = View(self.app)
            self.app.bind('ViewClass', viewClass)
            self.app.bind('View', viewClass.render)
github MasoniteFramework / masonite / tests / test_cache.py View on Github external
def setup_method(self):
        self.app = App()
        self.app.bind('CacheConfig', cache)
        self.app.bind('CacheDiskDriver', CacheDiskDriver)
        self.app.bind('CacheRedisDriver', CacheRedisDriver)
        self.app.bind('CacheManager', CacheManager(self.app))
        self.app.bind('Application', self.app)
        self.app.bind('Cache', self.app.make('CacheManager').driver('disk'))
        self.drivers = ['disk']
        if os.environ.get('REDIS_CACHE_DRIVER'):
            self.drivers.append('redis')
github MasoniteFramework / masonite / tests / core / test_container.py View on Github external
def test_app_simple_bind(self):
        app = App()
        app.simple(Request)
        self.assertEqual(app.providers, {Request: Request})
github MasoniteFramework / masonite / tests / core / test_requests.py View on Github external
def test_route_exists(self):
        app = App()
        app.bind('Request', self.request)
        app.bind('WebRoutes', [
            Get('/test/url', 'TestController@show').name('test.url'),
            Get('/test/url/@id', 'TestController@show').name('test.id')
        ])
        request = app.make('Request').load_app(app)

        self.assertEqual(request.route_exists('/test/url'), True)
        self.assertEqual(request.route_exists('/test/Not'), False)
github MasoniteFramework / masonite / tests / core / test_requests.py View on Github external
def test_request_route_returns_url_without_passing_args_with_current_param(self):
        app = App()
        app.bind('Request', self.request)
        app.bind('WebRoutes', [
            Get('/test/url', 'TestController@show').name('test.url'),
            Get('/test/url/@id', 'TestController@show').name('test.id')
        ])
        request = app.make('Request').load_app(app)
        request.url_params = {'id': 1}

        assert request.route('test.id') == '/test/url/1'