| | |
| | | 'HTTP_HOST':'example.com:80', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url() |
| | | result = request._partial_application_url() |
| | | self.assertEqual(result, 'http://example.com') |
| | | |
| | | def test_partial_application_url_with_http_host_default_port_https(self): |
| | |
| | | 'HTTP_HOST':'example.com:443', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url() |
| | | result = request._partial_application_url() |
| | | self.assertEqual(result, 'https://example.com') |
| | | |
| | | def test_partial_application_url_with_http_host_nondefault_port_http(self): |
| | |
| | | 'HTTP_HOST':'example.com:8080', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url() |
| | | result = request._partial_application_url() |
| | | self.assertEqual(result, 'http://example.com:8080') |
| | | |
| | | def test_partial_application_url_with_http_host_nondefault_port_https(self): |
| | |
| | | 'HTTP_HOST':'example.com:4443', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url() |
| | | result = request._partial_application_url() |
| | | self.assertEqual(result, 'https://example.com:4443') |
| | | |
| | | def test_partial_application_url_with_http_host_no_colon(self): |
| | |
| | | 'SERVER_PORT':'80', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url() |
| | | result = request._partial_application_url() |
| | | self.assertEqual(result, 'http://example.com') |
| | | |
| | | def test_partial_application_url_no_http_host(self): |
| | |
| | | 'SERVER_PORT':'80', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url() |
| | | result = request._partial_application_url() |
| | | self.assertEqual(result, 'http://example.com') |
| | | |
| | | def test_partial_application_replace_port(self): |
| | |
| | | 'SERVER_PORT':'80', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url(port=8080) |
| | | result = request._partial_application_url(port=8080) |
| | | self.assertEqual(result, 'http://example.com:8080') |
| | | |
| | | def test_partial_application_replace_scheme_https_special_case(self): |
| | |
| | | 'SERVER_PORT':'80', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url(scheme='https') |
| | | result = request._partial_application_url(scheme='https') |
| | | self.assertEqual(result, 'https://example.com') |
| | | |
| | | def test_partial_application_replace_scheme_https_special_case_avoid(self): |
| | |
| | | 'SERVER_PORT':'80', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url(scheme='https', port='8080') |
| | | result = request._partial_application_url(scheme='https', port='8080') |
| | | self.assertEqual(result, 'https://example.com:8080') |
| | | |
| | | def test_partial_application_replace_scheme_http_special_case(self): |
| | |
| | | 'SERVER_PORT':'8080', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url(scheme='http') |
| | | result = request._partial_application_url(scheme='http') |
| | | self.assertEqual(result, 'http://example.com') |
| | | |
| | | def test_partial_application_replace_scheme_http_special_case_avoid(self): |
| | |
| | | 'SERVER_PORT':'8000', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url(scheme='http', port='8080') |
| | | result = request._partial_application_url(scheme='http', port='8080') |
| | | self.assertEqual(result, 'http://example.com:8080') |
| | | |
| | | def test_partial_application_replace_host_no_port(self): |
| | |
| | | 'SERVER_PORT':'80', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url(host='someotherhost.com') |
| | | result = request._partial_application_url(host='someotherhost.com') |
| | | self.assertEqual(result, 'http://someotherhost.com') |
| | | |
| | | def test_partial_application_replace_host_with_port(self): |
| | |
| | | 'SERVER_PORT':'8000', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url(host='someotherhost.com:8080') |
| | | result = request._partial_application_url(host='someotherhost.com:8080') |
| | | self.assertEqual(result, 'http://someotherhost.com:8080') |
| | | |
| | | def test_partial_application_replace_host_and_port(self): |
| | |
| | | 'SERVER_PORT':'80', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url(host='someotherhost.com:8080', |
| | | port='8000') |
| | | result = request._partial_application_url(host='someotherhost.com:8080', |
| | | port='8000') |
| | | self.assertEqual(result, 'http://someotherhost.com:8000') |
| | | |
| | | def test_partial_application_replace_host_port_and_scheme(self): |
| | |
| | | 'SERVER_PORT':'80', |
| | | } |
| | | request = self._makeOne(environ) |
| | | result = request.partial_application_url( |
| | | result = request._partial_application_url( |
| | | host='someotherhost.com:8080', |
| | | port='8000', |
| | | scheme='https', |
| | |
| | | } |
| | | request = self._makeOne(environ) |
| | | request.script_name = '/abc' |
| | | result = request.partial_application_url() |
| | | result = request._partial_application_url() |
| | | self.assertEqual(result, 'http://example.com:8000/abc') |
| | | |
| | | class Test_route_url(unittest.TestCase): |