Porting cookie test to httpbin.org.
authorZbigniew Siciarz <antyqjon@gmail.com>
Thu, 16 Jun 2011 07:08:32 +0000 (09:08 +0200)
committerZbigniew Siciarz <antyqjon@gmail.com>
Thu, 16 Jun 2011 07:08:32 +0000 (09:08 +0200)
test_requests.py

index 87ccf8e..3c1a437 100755 (executable)
@@ -170,15 +170,11 @@ class RequestsTestSuite(unittest.TestCase):
 
     def test_cookie_jar(self):
 
-        # TODO: port to httpbin
-
         jar = cookielib.CookieJar()
         self.assertFalse(jar)
 
-        data = {'cn': 'requests_cookie', 'cv': 'awesome'}
-
-        r = requests.post('http://www.html-kit.com/tools/cookietester/', data=data, cookies=jar, allow_redirects=True)
-
+        url = httpbin('cookies', 'set', 'requests_cookie', 'awesome')
+        r = requests.get(url, cookies=jar)
         self.assertTrue(jar)
 
         cookie_found = False
@@ -188,6 +184,9 @@ class RequestsTestSuite(unittest.TestCase):
                 cookie_found = True
         self.assertTrue(cookie_found)
 
+        r = requests.get(httpbin('cookies'), cookies=jar)
+        self.assertTrue('awesome' in r.content)
+
 
     def test_decompress_gzip(self):