Ejemplo n.º 1
0
class SessionMiddlewareTests(unittest.TestCase):
    def setUp(self):
        super(SessionMiddlewareTests, self).setUp()
        self.middleware = SessionMiddleware()

    def test_default_cookie_name(self):
        self.assertEqual(self.middleware.cookie_name, "sessionid")

    def test_default_session_store(self):
        self.assertEqual(self.middleware.session_store, None)

    def test_raises_without_session_store(self):
        with self.assertRaises(Exception):
            self.middleware.dispatch(None, None)

    def test_persists_new_session_key(self):
        def view(request):
            request.session["key"] = "value"
            return Response()

        self.middleware.session_store = MemorySessionStore()
        response = self.middleware.dispatch(view, Request())

        self.assertIsNotNone(response.cookies["sessionid"].value)
Ejemplo n.º 2
0
 def setUp(self):
     super(SessionMiddlewareTests, self).setUp()
     self.middleware = SessionMiddleware()