Exemplo n.º 1
0
 def test_create_from_dict(self):
     url = Url({
         'scheme': 'http',
         'hostname': 'www.google.com',
         'fragment': 'frag',
         'port': 80,
         'path': '/path/path2',
         'query': 'q=test',
         'username': '******',
         'password': '******'
     })
     assert url.scheme == 'http'
     assert url.hostname == 'www.google.com'
     assert url.subdomain == 'www'
     assert url.fragment == 'frag'
     assert url.port == 80
     assert url.path == '/path/path2'
     assert url.path_index(0) == 'path'
     assert url.query == 'q=test'
     assert url.netloc == 'simon:[email protected]:80'
     assert not url.path_index(4)
Exemplo n.º 2
0
 def test_create_from_string(self):
     url = Url('http://*****:*****@www.google.com:80/path/path2?q=test#frag')
     assert url.scheme == 'http'
     assert url.hostname == 'www.google.com'
     assert url.subdomain == 'www'
     assert url.fragment == 'frag'
     assert url.port == 80
     assert url.path == '/path/path2'
     assert url.path_index(0) == 'path'
     assert url.query == 'q=test'
     assert url.username == 'simon'
     assert url.password == 'test'
     assert url.netloc == 'simon:[email protected]:80'