예제 #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')
예제 #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')
예제 #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')
예제 #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))))
예제 #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')
예제 #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>')
예제 #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')
예제 #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)
예제 #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), '')
예제 #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)
예제 #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)
예제 #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')
예제 #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')
예제 #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')