Example #1
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'
Example #2
0
 def test_create_from_dict_empty(self):
     url = Url({
         'hostname': 'www.google.com'
     })
     assert not url.fragment
     assert url.path == '/'
     assert not url.query
Example #3
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)
Example #4
0
    def url(self):
        """Generates a watson.http.uri.Url object based on Request.server variables.

        Usage:
            request = ...
            print(request.url.path) # /

        Returns:
            A watson.http.uri.Url object
        """
        if not self._url:
            self._url = Url(request_uri(self._server))
        return self._url
Example #5
0
 def test_params(self):
     url = Url('http://www.google.com/search;test=blah')
     assert url.params == 'test=blah'