Skip to content

Commit

Permalink
Added a unit test for setting a cookie with max_age
Browse files Browse the repository at this point in the history
  • Loading branch information
leekchan committed Sep 11, 2014
1 parent cf724c3 commit 3624947
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tornado/test/web_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,16 @@ def get(self):
# 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):
Expand Down Expand Up @@ -222,6 +227,12 @@ def test_set_cookie_overwrite(self):
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):
Expand Down

0 comments on commit 3624947

Please sign in to comment.