Beispiel #1
0
 def test_verify_that_cookies_are_expiring_properly(self):
     #Verify that cookies expire based on the expiration date
     middleware = LocalStoreMiddleware()
     req = self._fake_request()
     resp = HttpResponse()
     cookies = {'dolphin_test_cookie1':(True, 0)}
     LocalStoreMiddleware.local.setdefault('dolphin_cookies', cookies)
     response = middleware.process_response(req, resp)
     self.assertEqual(response.cookies.keys(), SimpleCookie(cookies).keys())
     #Clear cookies
     response.cookies = {}
     #Verify that we've cleaned up the cookies
     self.assertNotEqual(response.cookies.keys(), SimpleCookie(cookies).keys())
Beispiel #2
0
 def test_cookies_in_middleware(self):
     #Verify that cookies are being stored via dolphin's middleware response process
     middleware = LocalStoreMiddleware()
     req = self._fake_request()
     resp = HttpResponse()
     cookies = {'dolphin_test_cookie1':(True, self.one_hour_later),  'dolphin_test_cookie2':(False, self.one_hour_later)}
     LocalStoreMiddleware.local.setdefault('dolphin_cookies', cookies)
     response = middleware.process_response(req, resp)
     self.assertEqual(response.cookies.keys(), SimpleCookie(cookies).keys())
     #Clear cookies
     response.cookies = {}
     #Verify that we've cleaned up the cookies
     self.assertNotEqual(response.cookies.keys(), SimpleCookie(cookies).keys())