示例#1
0
 def test_cookie_jar_can_render_multiple_cookies_with_different_options(self):
     cookiejar = CookieJar()
     cookiejar.add("cookie1", "name", path="/")
     self.assertEqual(
         cookiejar.render_response(),
         [("Set-Cookie", "cookie1=name;HttpOnly;Path=/;")],
     )
示例#2
0
 def test_cookie_with_expired_already(self):
     cookiejar = CookieJar()
     time = cookie_expire_time("expired")
     cookiejar.add("cookie1", "name", path="/", expires=time, timezone="GMT")
     self.assertEqual(
         cookiejar.render_response(),
         [("Set-Cookie", f"cookie1=name;HttpOnly;Expires={time} GMT;Path=/;")],
     )
示例#3
0
 def test_cookie_jar_can_render_multiple_cookies(self):
     cookiejar = CookieJar()
     cookiejar.add("cookie1", "name", http_only=False)
     cookiejar.add("cookie2", "name", http_only=False)
     self.assertEqual(
         cookiejar.render_response(),
         [("Set-Cookie", "cookie1=name;"), ("Set-Cookie", "cookie2=name;")],
     )
示例#4
0
 def test_cookie_can_load(self):
     cookiejar = CookieJar()
     cookiejar.add("cookie1", "name", http_only=False)
     cookiejar.load("csrf_token=tok")
     self.assertEqual(cookiejar.render_response(),
                      [("Set-Cookie", "cookie1=name;")])
     self.assertEqual(cookiejar.get("csrf_token").value, "tok")
示例#5
0
 def test_cookie_can_make_secure_cookies(self):
     cookiejar = CookieJar()
     cookiejar.add("cookie1", "name", http_only=False, secure=True)
     self.assertEqual(
         cookiejar.render_response(), [("Set-Cookie", "cookie1=name;Secure;Path=/;")]
     )
示例#6
0
 def test_cookies_can_get_set(self):
     cookiejar = CookieJar()
     cookiejar.add("cookie", "name")
     self.assertEqual(cookiejar.get("cookie").value, "name")
     self.assertEqual(cookiejar.get("cookie").name, "cookie")
示例#7
0
 def test_cookie_jar_can_render_cookie_string(self):
     cookiejar = CookieJar()
     cookiejar.add("cookie", "name", http_only=False)
     self.assertEqual(
         cookiejar.render_response(), [("Set-Cookie", "cookie=name;Path=/;")]
     )
示例#8
0
 def test_cookies_can_put_to_dict(self):
     cookiejar = CookieJar()
     cookiejar.add("cookie", "name")
     self.assertEqual(cookiejar.to_dict(), {"cookie": "name"})