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)
Exemple #2
0
    def test_request_validation_redirects_back_with_session(self):
        wsgi = generate_wsgi()
        self.app.bind('Application', self.app)
        self.app.bind('SessionCookieDriver', SessionCookieDriver)
        self.app.bind('Environ', wsgi)

        request = self.app.make('Request')
        request.load_environ(wsgi)

        request.request_variables = {'id': 1, 'name': 'Joe'}

        errors = request.validate(required('user'))

        request.session = SessionManager(self.app).driver('cookie')
        request.key('UKLAdrye6pZG4psVRPZytukJo2-A_Zxbo0VaqR5oig8=')
        self.assertEqual(
            request.redirect('/login').with_errors(errors).redirect_url,
            '/login')
        self.assertEqual(
            request.redirect('/login').with_errors(errors).session.get(
                'errors'), {'user': ['The user field is required.']})
Exemple #3
0
 def register(self):
     self.app.bind('SessionConfig', session)
     self.app.bind('SessionMemoryDriver', SessionMemoryDriver)
     self.app.bind('SessionCookieDriver', SessionCookieDriver)
     self.app.bind('SessionManager', SessionManager(self.app))