Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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'))
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)
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)
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())
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)
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)
def setUp(self):
self.request = Request(generate_wsgi()).key(
'NCTpkICMlTXie5te9nJniMj9aVbPM6lsjeq5iDZ0dqY=')
self.request.activate_subdomains()
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
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)