Ejemplo n.º 1
0
 def test_parse_url(self):
     host, port, resource = HttpRequest._parse_url('127.0.0.1')
     self.assertEqual(host, '127.0.0.1')
     self.assertIs(port, None)
     self.assertEqual(resource, '/')
     host, port, resource = HttpRequest._parse_url('http://localhost')
     self.assertEqual(host, 'localhost')
     self.assertIs(port, None)
     self.assertEqual(resource, '/')
     host, port, resource = HttpRequest._parse_url('http://localhost/foo/bar')
     self.assertEqual(host, 'localhost')
     self.assertIs(port, None)
     self.assertEqual(resource, '/foo/bar')
     host, port, resource = HttpRequest._parse_url('http://localhost:80/foo/bar')
     self.assertEqual(host, 'localhost')
     self.assertEqual(port, 80)
     self.assertEqual(resource, '/foo/bar')
Ejemplo n.º 2
0
 def test_parse_url(self):
     host, port, resource = HttpRequest._parse_url('127.0.0.1')
     self.assertEqual(host, '127.0.0.1')
     self.assertIs(port, None)
     self.assertEqual(resource, '/')
     host, port, resource = HttpRequest._parse_url('http://localhost')
     self.assertEqual(host, 'localhost')
     self.assertIs(port, None)
     self.assertEqual(resource, '/')
     host, port, resource = HttpRequest._parse_url(
         'http://localhost/foo/bar')
     self.assertEqual(host, 'localhost')
     self.assertIs(port, None)
     self.assertEqual(resource, '/foo/bar')
     host, port, resource = HttpRequest._parse_url(
         'http://localhost:80/foo/bar')
     self.assertEqual(host, 'localhost')
     self.assertEqual(port, 80)
     self.assertEqual(resource, '/foo/bar')
Ejemplo n.º 3
0
 def test_send_http_request_get(self):
     request = HttpRequest('http://localhost')
     response = request.send()
     self.assertEqual(response.status, 200)
     self.assertTrue(response.body)
Ejemplo n.º 4
0
 def test_send_http_request_options(self):
     request = HttpRequest('http://localhost', method='OPTIONS')
     response = request.send()
     self.assertEqual(response.status, 200)
Ejemplo n.º 5
0
 def test_send_http_request_get(self):
     request = HttpRequest('http://localhost')
     response = request.send()
     self.assertEqual(response.status, 200)
     self.assertTrue(response.body)
Ejemplo n.º 6
0
 def test_send_http_request_options(self):
     request = HttpRequest('http://localhost', method='OPTIONS')
     response = request.send()
     self.assertEqual(response.status, 200)