def test__parses_URL_with_IPv6_address(self): ip = factory.make_ipv6_address().encode("ascii") path = factory.make_name("path").encode("ascii") uri = get_patched_URI().fromBytes(b"http://[%s]/%s" % (ip, path)) self.expectThat(uri.host, Equals(b"%s" % ip)) self.expectThat(uri.path, Equals(b"/%s" % path)) self.expectThat(uri.port, Equals(80))
def test__parses_URL_with_IPv6_address(self): ip = factory.make_ipv6_address().encode('ascii') path = factory.make_name('path').encode('ascii') uri = get_patched_URI().fromBytes(b'http://[%s]/%s' % (ip, path)) self.expectThat(uri.host, Equals(b'%s' % ip)) self.expectThat(uri.path, Equals(b'/%s' % path)) self.expectThat(uri.port, Equals(80))
def test__parses_URL_with_hostname(self): hostname = factory.make_name("host").encode("ascii") path = factory.make_name("path").encode("ascii") uri = get_patched_URI().fromBytes(b"http://%s/%s" % (hostname, path)) self.expectThat(uri.host, Equals(hostname)) self.expectThat(uri.path, Equals(b"/%s" % path)) self.expectThat(uri.port, Equals(80))
def test__parses_URL_with_hostname(self): hostname = factory.make_name('host').encode('ascii') path = factory.make_name('path').encode('ascii') uri = get_patched_URI().fromBytes(b'http://%s/%s' % (hostname, path)) self.expectThat(uri.host, Equals(hostname)) self.expectThat(uri.path, Equals(b'/%s' % path)) self.expectThat(uri.port, Equals(80))
def test__parses_URL_with_IPv4_address_and_port(self): ip = factory.make_ipv4_address().encode("ascii") port = factory.pick_port() path = factory.make_name("path").encode("ascii") uri = get_patched_URI().fromBytes(b"http://%s:%d/%s" % (ip, port, path)) self.expectThat(uri.host, Equals(ip)) self.expectThat(uri.path, Equals(b"/%s" % path)) self.expectThat(uri.port, Equals(port))