def test_cookie(self): response = Request(httpbin('cookies', 'set?name=dragline')).send() response = Request(httpbin('cookies'), cookies=response.cookies).send() self.assertEqual(response.json()['cookies']['name'], 'dragline') response = Request(httpbin('/cookies/delete?name')).send() response = Request(httpbin('cookies'), cookies={'name': 'dragline2'}).send() self.assertEqual(response.json()['cookies']['name'], 'dragline2')
def test_redirect(self): response = Request(httpbin('redirect', '4')).send() self.assertEqual(httpbin('get'), response.json()['url']) self.assertEqual(response.status_code, 200) response = Request(httpbin('redirect', '4'), allow_redirects=False).send() self.assertEqual(response.status_code, 302)
def test_headers(self): headers = {"user-agent": "dragline"} response = Request(httpbin('user-agent'), headers=headers).send() self.assertEqual(headers, response.json())
def test_post_raw(self): data = 'dragline' response = Request(httpbin('post'), data=data).send() self.assertEqual(data, response.json()['data'])
def test_post_form(self): data = {'name': 'dragline'} response = Request(httpbin('post'), data=data).send() self.assertEqual(data, response.json()['form'])
def test_get(self): response = Request(httpbin('get')).send() self.assertEqual(httpbin('get'), response.json()['url'])