Exemplo n.º 1
0
 def test_no_scheme_user_and_pw(self):
     url = URL('foo:bar@foohost:9999')
     self.assertEqual(url.scheme, 'http')
     self.assertEqual(url.host, 'foohost')
     self.assertEqual(url.port, 9999)
     self.assertEqual(url.user, 'foo')
     self.assertEqual(url.password, 'bar')
Exemplo n.º 2
0
 def test_authentication(self):
     url = URL('https://*****:*****@localhost:123')
     self.assertEqual(url.scheme, 'https')
     self.assertEqual(url.host, 'localhost')
     self.assertEqual(url.port, 123)
     self.assertEqual(url.user, 'foo')
     self.assertEqual(url.password, 'bar')
Exemplo n.º 3
0
 def test_attributes(self):
     url = URL('http://*****:*****@localhost:123/foo')
     self.assertEqual(url.scheme, 'http')
     self.assertEqual(url.user, 'user')
     self.assertEqual(url.password, 'pw')
     self.assertEqual(url.host, 'localhost')
     self.assertEqual(url.port, 123)
     self.assertEqual(url.path, '/foo')
Exemplo n.º 4
0
 def test_url_scrape(self):
     from stig.client.utils import URL
     self.check_filter(
         TrackerFilter,
         filter_names=('url-scrape', 'sc'),
         items=({
             'id': 1,
             'url-scrape': URL('http://abc.example.com:1234/foo/scrape')
         }, {
             'id': 2,
             'url-scrape': URL('http://abc.example.com:1234/bar/scrape')
         }, {
             'id': 3,
             'url-scrape': URL('http://def.example.com:4321/scrape')
         }),
         test_cases=(('{name}', (1, 2, 3)), ('!{name}', ()),
                     ('{name}=http://abc.example.com:1234/bar/scrape',
                      (2, )), ('{name}~abc', (1, 2))))
Exemplo n.º 5
0
    def test_mutability_and_cache(self):
        url = URL('https://foo.example.com:123/foo')
        url.port = 321
        url.host = 'bar.example.com'
        url.scheme = 'http'
        self.assertEqual(str(url), 'http://bar.example.com:321/foo')

        self.assertEqual(url.domain, 'example.com')
        url.host = 'foo.bar.com'
        self.assertEqual(url.domain, 'bar.com')
        self.assertEqual(str(url), 'http://foo.bar.com:321/foo')
Exemplo n.º 6
0
 def test_repr(self):
     url = URL('https://*****:*****@localhost:123/foo/bar/baz')
     self.assertEqual(repr(url),
                      '<URL https://foo:bar@localhost:123/foo/bar/baz>')
Exemplo n.º 7
0
 def test_str(self):
     url = URL('https://*****:*****@localhost:123')
     self.assertEqual(str(url), 'https://*****:*****@localhost:123')
     url = URL('localhost')
     self.assertEqual(str(url), 'http://localhost')
Exemplo n.º 8
0
 def test_no_scheme_with_port(self):
     url = URL('foohost:9999')
     self.assertEqual(url.scheme, 'http')
     self.assertEqual(url.host, 'foohost')
     self.assertEqual(url.port, 9999)
Exemplo n.º 9
0
 def test_empty_string(self):
     url = URL('')
     self.assertEqual(url.scheme, None)
     self.assertEqual(url.host, None)
     self.assertEqual(url.port, None)
     self.assertEqual(str(url), '')
Exemplo n.º 10
0
 def test_no_scheme(self):
     url = URL('foohost')
     self.assertEqual(url.scheme, 'http')
     self.assertEqual(url.host, 'foohost')
     self.assertEqual(url.port, None)
Exemplo n.º 11
0
 def test_invalid_port(self):
     url = URL('foohost:70123')
     self.assertEqual(url.scheme, 'http')
     self.assertEqual(url.host, 'foohost')
     self.assertEqual(url.port, 70123)
Exemplo n.º 12
0
 def test_authentication_empty_user_and_password(self):
     url = URL(':@localhost')
     self.assertEqual(url.user, None)
     self.assertEqual(url.password, None)
     self.assertEqual(url.host, 'localhost')
Exemplo n.º 13
0
 def test_authentication_no_password(self):
     url = URL('foo@localhost')
     self.assertEqual(url.user, 'foo')
     self.assertEqual(url.password, None)
     self.assertEqual(url.host, 'localhost')
Exemplo n.º 14
0
 def test_no_scheme(self):
     url = URL('localhost/foo')
     self.assertEqual(url.scheme, 'http')
     self.assertEqual(url.host, 'localhost')
     self.assertEqual(url.port, None)
     self.assertEqual(url.path, '/foo')