示例#1
0
    def test_with_auth_with_two_args_replaces_whole_auth_string_with_username_and_password(
            self):
        # Replaces username-only auth string
        assert (Netloc('*****@*****.**').with_auth(
            'zack', '1234') == 'zack:[email protected]')

        # Replaces username and password.
        assert (Netloc('alice:[email protected]').with_auth(
            'zack', '1234') == 'zack:[email protected]')
示例#2
0
 def test_without_auth_removes_entire_auth_string(self):
     # No username or password => no-op.
     netloc = Netloc('github.com')
     assert netloc.without_auth() == 'github.com'
     # Username-only.
     netloc = Netloc('*****@*****.**')
     assert netloc.without_auth() == 'github.com'
     # Username and password.
     netloc = Netloc('alice:[email protected]')
     assert netloc.without_auth() == 'github.com'
示例#3
0
 def test_without_auth_removes_entire_auth_string(self):
     # No username or password => no-op.
     netloc = Netloc(u'github.com')
     assert netloc.without_auth() == u'github.com'
     # Username-only.
     netloc = Netloc(u'*****@*****.**')
     assert netloc.without_auth() == u'github.com'
     # Username and password.
     netloc = Netloc(u'alice:[email protected]')
     assert netloc.without_auth() == u'github.com'
示例#4
0
 def test_with_port_adds_port(self):
     assert Netloc('github.com').with_port(443) == 'github.com:443'
示例#5
0
 def test_with_auth_with_one_arg_replaces_whole_auth_string_with_username(
         self):
     assert (Netloc('alice:[email protected]').with_auth('zack') ==
             '*****@*****.**')
示例#6
0
 def test_with_auth_with_two_args_adds_username_and_password(self):
     assert (Netloc('github.com').with_auth(
         'zack', '1234') == 'zack:[email protected]')
示例#7
0
 def test_with_auth_with_one_arg_adds_username(self):
     assert (Netloc('github.com').with_auth('zack') == '*****@*****.**')
示例#8
0
 def test_auth(self):
     assert Netloc('github.com').auth == (None, None)
     assert Netloc('*****@*****.**').auth == ('zack', None)
     assert Netloc('zack:[email protected]').auth == ('zack', '1234')
示例#9
0
 def test_without_port_removes_port(self):
     assert Netloc('github.com:443').without_port() == 'github.com'
示例#10
0
 def test_with_password_on_a_netloc_with_no_username_raises_ValueError(
         self):
     assert_raises(ValueError,
                   lambda: Netloc('github.com').with_password('1234'))
示例#11
0
 def test_hostname(self):
     assert Netloc('zack:[email protected]:443').hostname == 'github.com'
示例#12
0
 def test_port(self):
     assert Netloc('github.com:443').port == 443
     assert Netloc('github.com').port is None
示例#13
0
 def test_with_username_replaces_username(self):
     assert (Netloc('*****@*****.**').with_username('alice') ==
             '*****@*****.**')
     assert (Netloc('zack:[email protected]').with_username('alice') ==
             'alice:[email protected]')
示例#14
0
 def test_without_username_removes_username(self):
     assert Netloc('github.com').without_username() == 'github.com'
     assert Netloc('*****@*****.**').without_username() == 'github.com'
     # Removing the username will also remove the password.
     assert Netloc(
         'zack:[email protected]:443').without_username() == 'github.com:443'
示例#15
0
 def test_with_username_adds_username(self):
     assert Netloc('github.com').with_username('zack') == '*****@*****.**'
示例#16
0
 def test_username(self):
     assert Netloc('github.com').username is None
     assert Netloc('*****@*****.**').username == 'zack'
     assert Netloc('zack:[email protected]').username == 'zack'
示例#17
0
 def test_preserves_hash_of_the_original_string(self):
     netloc = 'zack:[email protected]:443'
     assert hash(Netloc(netloc)) == hash(netloc)
示例#18
0
 def test_preserves_equality_of_the_original_string(self):
     netloc = 'zack:[email protected]:443'
     assert Netloc(netloc) == netloc
示例#19
0
 def test_with_password_replaces_password(self):
     assert (Netloc('zack:[email protected]:443').with_password('5678') ==
             'zack:[email protected]:443')
示例#20
0
 def test_password(self):
     assert Netloc('github.com').password is None
     assert Netloc('*****@*****.**').password is None
     assert Netloc('zack:[email protected]').password == '1234'
示例#21
0
 def test_with_port_replaces_port(self):
     assert Netloc('github.com:443').with_port(80) == 'github.com:80'
示例#22
0
 def test_with_hostname_replaces_hostname(self):
     assert (Netloc('zack:[email protected]:443').with_hostname('example.com')
             == 'zack:[email protected]:443')
示例#23
0
 def test_with_password_adds_password(self):
     assert (Netloc('*****@*****.**').with_password('1234') ==
             'zack:[email protected]')