How to use masonite - 10 common examples

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_container.py View on Github external
def test_app_simple_bind_init(self):
        app = App()
        req = Request()
        app.simple(req)
        self.assertEqual(app.providers, {Request: req})
github MasoniteFramework / masonite / tests / core / test_managers_mail_manager.py View on Github external
def test_send_mail_sends(self):
        if env('RUN_MAIL'):
            self.app.bind('MailSmtpDriver', MailDriver)

            self.assertTrue(MailManager(self.app).driver('smtp').to('idmann509@gmail.com').send('hi'))
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})