~ubuntu-branches/ubuntu/raring/requests/raring

« back to all changes in this revision

Viewing changes to tests/test_requests_ext.py

  • Committer: Package Import Robot
  • Author(s): Daniele Tricoli
  • Date: 2012-05-04 14:34:47 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20120504143447-3psyffw2slct0a1j
Tags: 0.12.1-1
* New upstream release
* debian/control
  - Added python-oauthlib to python-requests' Recommends field
* debian/patches/01_do-not-use-python-certifi.patch
  - Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
                         'php')
105
105
        assert r.ok
106
106
 
107
 
 
108
 
 
 
107
    def test_cookies_on_redirects(self):
 
108
        """Test interaction between cookie handling and redirection."""
 
109
        # get a cookie for tinyurl.com ONLY
 
110
        s = requests.session()
 
111
        s.get(url='http://tinyurl.com/preview.php?disable=1')
 
112
        # we should have set a cookie for tinyurl: preview=0
 
113
        self.assertIn('preview', s.cookies)
 
114
        self.assertEqual(s.cookies['preview'], '0')
 
115
        self.assertEqual(list(s.cookies)[0].name, 'preview')
 
116
        self.assertEqual(list(s.cookies)[0].domain, 'tinyurl.com')
 
117
 
 
118
        # get cookies on another domain
 
119
        r2 = s.get(url='http://httpbin.org/cookies')
 
120
        # the cookie is not there
 
121
        self.assertNotIn('preview', json.loads(r2.text)['cookies'])
 
122
 
 
123
        # this redirects to another domain, httpbin.org
 
124
        # cookies of the first domain should NOT be sent to the next one
 
125
        r3 = s.get(url='http://tinyurl.com/7zp3jnr')
 
126
        assert r3.url == 'http://httpbin.org/cookies'
 
127
        self.assertNotIn('preview', json.loads(r2.text)['cookies'])
109
128
 
110
129
if __name__ == '__main__':
111
130
    unittest.main()