masonite.request.Request - python examples

Here are the examples of the python api masonite.request.Request taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

27 Examples 7

3 View Complete Implementation : test_container.py
Copyright MIT License
Author : MasoniteFramework
    def setUp(self):
        self.app = App()
        self.app.bind('Request', Request(None))
        self.app.bind('MockObject', MockObject)
        self.app.bind('GetObject', GetObject)
        self.app.bind('Container', self.app)

3 View Complete Implementation : test_container.py
Copyright MIT License
Author : MasoniteFramework
    def test_can_past_variables(self):
        app = App()
        req = Request()
        app.bind('Request', req)
        obj = app.resolve(self._test_resolves_variables, 'test1', 'test2')
        self.astertEqual(obj[0], 'test1')
        self.astertEqual(obj[1], req)
        self.astertEqual(obj[2], 'test2')

3 View Complete Implementation : test_extends.py
Copyright MIT License
Author : MasoniteFramework
    def test_hidden_form_request_method_changes_request_method(self):
        app = App()
        wsgi_request['QUERY_STRING'] = '__method=PUT'
        request_clast = Request(wsgi_request)

        app.bind('Request', request_clast)
        request = app.make('Request').load_app(app)

        self.astertEqual(request.environ['REQUEST_METHOD'], 'PUT')

3 View Complete Implementation : test_extends.py
Copyright MIT License
Author : MasoniteFramework
    def test_get_json_input(self):
        json_wsgi = wsgi_request
        json_wsgi['REQUEST_METHOD'] = 'POST'
        json_wsgi['CONTENT_TYPE'] = 'application/json'
        json_wsgi['QUERY_STRING'] = ''
        json_wsgi['wsgi.input'] = MockWsgiInput()
        Route(json_wsgi)
        request_obj = Request(json_wsgi)

        self.astertIsInstance(request_obj.request_variables, dict)
        self.astertEqual(request_obj.input('id'), 1)
        self.astertEqual(request_obj.input('test'), 'testing')

3 View Complete Implementation : test_requests.py
Copyright MIT License
Author : MasoniteFramework
    def test_request_gets_all_headers(self):
        app = App()
        app.bind('Request', Request(wsgi_request))
        request = app.make('Request').load_app(app)

        request.header('TEST1', 'set_this_item')
        self.astertEqual(request.get_headers(), [('TEST1', 'set_this_item')])

3 View Complete Implementation : test_requests.py
Copyright MIT License
Author : MasoniteFramework
    def test_request_sets_request_method(self):
        wsgi = generate_wsgi()
        wsgi['QUERY_STRING'] = '__method=PUT'
        request = Request(wsgi)

        astert request.has('__method')
        self.astertEqual(request.input('__method'), 'PUT')
        self.astertEqual(request.get_request_method(), 'PUT')

3 View Complete Implementation : test_routes.py
Copyright MIT License
Author : MasoniteFramework
    def test_redirect_route(self):
        route = Redirect('/test1', '/test2')
        request = Request(generate_wsgi())
        route.load_request(request)
        request.load_app(App())

        route.get_response()
        self.astertTrue(request.is_status(302))
        self.astertEqual(request.redirect_url, '/test2')

3 View Complete Implementation : test_routes.py
Copyright MIT License
Author : MasoniteFramework
    def test_redirect_can_use_301(self):
        request = Request(generate_wsgi())
        route = Redirect('/test1', '/test3', status=301)

        route.load_request(request)
        request.load_app(App())
        route.get_response()
        self.astertTrue(request.is_status(301))
        self.astertEqual(request.redirect_url, '/test3')

3 View Complete Implementation : test_service_provider.py
Copyright MIT License
Author : MasoniteFramework
    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.astertEqual(self.app.resolve(ContainerTest().testboot), self.app.make('Request'))

3 View Complete Implementation : test_session.py
Copyright MIT License
Author : MasoniteFramework
    def setUp(self):
        wsgi_request = generate_wsgi()
        self.app = App()
        self.app.bind('Environ', wsgi_request)
        self.app.bind('Request', Request(wsgi_request))
        self.app.bind('SessionConfig', session)
        self.app.bind('SessionCookieDriver', SessionCookieDriver)
        self.app.bind('SessionMemoryDriver', SessionMemoryDriver)
        self.app.bind('SessionManager', SessionManager(self.app))
        self.app.bind('Application', self.app)