Exemplo n.º 1
0
 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')
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 def test_headers(self):
     headers = {"user-agent": "dragline"}
     response = Request(httpbin('user-agent'), headers=headers).send()
     self.assertEqual(headers, response.json())
Exemplo n.º 4
0
 def test_post_raw(self):
     data = 'dragline'
     response = Request(httpbin('post'), data=data).send()
     self.assertEqual(data, response.json()['data'])
Exemplo n.º 5
0
 def test_post_form(self):
     data = {'name': 'dragline'}
     response = Request(httpbin('post'), data=data).send()
     self.assertEqual(data, response.json()['form'])
Exemplo n.º 6
0
 def test_get(self):
     response = Request(httpbin('get')).send()
     self.assertEqual(httpbin('get'), response.json()['url'])