]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Added a unit test for setting a cookie with max_age 1179/head
authorLee Kyoung chan <leekchan@gmail.com>
Thu, 11 Sep 2014 13:16:44 +0000 (22:16 +0900)
committerLee Kyoung chan <leekchan@gmail.com>
Thu, 11 Sep 2014 13:16:44 +0000 (22:16 +0900)
tornado/test/web_test.py

index 1ad3794cbcc4996f369e44b00d113b94f4f9b981..6593cbb4c02c8f1c2a798cda28cefd9112014ccb 100644 (file)
@@ -163,11 +163,16 @@ class CookieTest(WebTestCase):
                 # Attributes from the first call are not carried over.
                 self.set_cookie("a", "e")
 
+        class SetCookieMaxAgeHandler(RequestHandler):
+            def get(self):
+                self.set_cookie("foo", "bar", max_age=10)
+
         return [("/set", SetCookieHandler),
                 ("/get", GetCookieHandler),
                 ("/set_domain", SetCookieDomainHandler),
                 ("/special_char", SetCookieSpecialCharHandler),
                 ("/set_overwrite", SetCookieOverwriteHandler),
+                ("/set_max_age", SetCookieMaxAgeHandler),
                 ]
 
     def test_set_cookie(self):
@@ -222,6 +227,12 @@ class CookieTest(WebTestCase):
         self.assertEqual(sorted(headers),
                          ["a=e; Path=/", "c=d; Domain=example.com; Path=/"])
 
+    def test_set_cookie_max_age(self):
+        response = self.fetch("/set_max_age")
+        headers = response.headers.get_list("Set-Cookie")
+        self.assertEqual(sorted(headers),
+                         ["foo=bar; Max-Age=10; Path=/"])
+
 
 class AuthRedirectRequestHandler(RequestHandler):
     def initialize(self, login_url):