Add a unit test for server expiring cookies from session
authorChase Sterling <chase.sterling@gmail.com>
Fri, 5 Apr 2013 02:40:27 +0000 (22:40 -0400)
committerChase Sterling <chase.sterling@gmail.com>
Fri, 5 Apr 2013 02:40:27 +0000 (22:40 -0400)
test_requests.py

index 93b8123..c0cb054 100644 (file)
@@ -124,6 +124,19 @@ class RequestsTestCase(unittest.TestCase):
         r = s.get(httpbin('redirect/1'))  # redirects to httpbin('get')
         self.assertTrue("Cookie" in r.json()["headers"])
 
+    def test_cookie_removed_on_expire(self):
+        s = requests.session()
+        s.get(httpbin('cookies/set?foo=bar'))
+        self.assertTrue(s.cookies['foo'] == 'bar')
+        s.get(
+            httpbin('response-headers'),
+            params={
+                'Set-Cookie':
+                    'foo=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT'
+            }
+        )
+        self.assertNotIn('foo', s.cookies)
+
     def test_user_agent_transfers(self):
 
         heads = {