794
794
class TestParseURL(TestCase):
796
def test_parse_url(self):
797
self.assertEqual(urlutils.parse_url('http://example.com:80/one'),
798
('http', None, None, 'example.com', 80, '/one'))
799
self.assertEqual(urlutils.parse_url('http://[1:2:3::40]/one'),
800
('http', None, None, '1:2:3::40', None, '/one'))
801
self.assertEqual(urlutils.parse_url('http://[1:2:3::40]:80/one'),
802
('http', None, None, '1:2:3::40', 80, '/one'))
796
def test_parse_simple(self):
797
parsed = urlutils.parse_url('http://example.com:80/one')
798
self.assertEquals(('http', None, None, 'example.com', 80, '/one'),
802
parsed = urlutils.parse_url('http://[1:2:3::40]/one')
803
self.assertEquals(('http', None, None, '1:2:3::40', None, '/one'),
806
def test_ipv6_port(self):
807
parsed = urlutils.parse_url('http://[1:2:3::40]:80/one')
808
self.assertEquals(('http', None, None, '1:2:3::40', 80, '/one'),
812
class TestURL(TestCase):
814
def test_parse_simple(self):
815
parsed = urlutils.URL.from_string('http://example.com:80/one')
816
self.assertEquals('http', parsed.scheme)
817
self.assertIs(None, parsed.user)
818
self.assertIs(None, parsed.password)
819
self.assertEquals('example.com', parsed.host)
820
self.assertEquals(80, parsed.port)
821
self.assertEquals('/one', parsed.path)
824
parsed = urlutils.URL.from_string('http://[1:2:3::40]/one')
825
self.assertEquals('http', parsed.scheme)
826
self.assertIs(None, parsed.port)
827
self.assertIs(None, parsed.user)
828
self.assertIs(None, parsed.password)
829
self.assertEquals('1:2:3::40', parsed.host)
830
self.assertEquals('/one', parsed.path)
832
def test_ipv6_port(self):
833
parsed = urlutils.URL.from_string('http://[1:2:3::40]:80/one')
834
self.assertEquals('http', parsed.scheme)
835
self.assertEquals('1:2:3::40', parsed.host)
836
self.assertIs(None, parsed.user)
837
self.assertIs(None, parsed.password)
838
self.assertEquals(80, parsed.port)
839
self.assertEquals('/one', parsed.path)
841
def test_quoted(self):
842
parsed = urlutils.URL.from_string(
843
'http://ro%62ey:h%40t@ex%41mple.com:2222/path')
844
self.assertEquals(parsed.quoted_host, 'ex%41mple.com')
845
self.assertEquals(parsed.host, 'exAmple.com')
846
self.assertEquals(parsed.port, 2222)
847
self.assertEquals(parsed.quoted_user, 'ro%62ey')
848
self.assertEquals(parsed.user, 'robey')
849
self.assertEquals(parsed.quoted_password, 'h%40t')
850
self.assertEquals(parsed.password, 'h@t')
851
self.assertEquals(parsed.path, '/path')
854
parsed1 = urlutils.URL.from_string('http://[1:2:3::40]:80/one')
855
parsed2 = urlutils.URL.from_string('http://[1:2:3::40]:80/one')
856
self.assertEquals(parsed1, parsed2)
857
self.assertEquals(parsed1, parsed1)
858
parsed2.path = '/two'
859
self.assertNotEquals(parsed1, parsed2)
862
parsed = urlutils.URL.from_string('http://[1:2:3::40]:80/one')
864
"<URL('http', None, None, '1:2:3::40', 80, '/one')>",