Exemple #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]')
Exemple #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'
Exemple #3
0
 def test_with_auth_with_two_args_adds_username_and_password(self):
     assert (Netloc('github.com').with_auth('zack', '1234') ==
             'zack:[email protected]')
Exemple #4
0
 def test_with_auth_with_one_arg_replaces_whole_auth_string_with_username(self):
     assert (Netloc('alice:[email protected]').with_auth('zack') ==
             '*****@*****.**')
Exemple #5
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')
Exemple #6
0
 def test_with_auth_with_one_arg_adds_username(self):
     assert (Netloc('github.com').with_auth('zack') ==
             '*****@*****.**')
Exemple #7
0
 def test_with_port_replaces_port(self):
     assert Netloc('github.com:443').with_port(80) == 'github.com:80'
Exemple #8
0
 def test_with_hostname_replaces_hostname(self):
     assert (Netloc('zack:[email protected]:443').with_hostname('example.com') ==
             'zack:[email protected]:443')
Exemple #9
0
 def test_preserves_equality_of_the_original_string(self):
     netloc = 'zack:[email protected]:443'
     assert Netloc(netloc) == netloc
Exemple #10
0
 def test_password(self):
     assert Netloc('github.com').password is None
     assert Netloc('*****@*****.**').password is None
     assert Netloc('zack:[email protected]').password == '1234'
Exemple #11
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'
Exemple #12
0
 def test_with_username_replaces_username(self):
     assert (Netloc('*****@*****.**').with_username('alice') ==
             '*****@*****.**')
     assert (Netloc('zack:[email protected]').with_username('alice') ==
             'alice:[email protected]')
Exemple #13
0
 def test_with_username_adds_username(self):
     assert Netloc('github.com').with_username('zack') == '*****@*****.**'
Exemple #14
0
 def test_username(self):
     assert Netloc('github.com').username is None
     assert Netloc('*****@*****.**').username == 'zack'
     assert Netloc('zack:[email protected]').username == 'zack'
Exemple #15
0
 def test_preserves_hash_of_the_original_string(self):
     netloc = 'zack:[email protected]:443'
     assert hash(Netloc(netloc)) == hash(netloc)
Exemple #16
0
 def test_without_port_removes_port(self):
     assert Netloc('github.com:443').without_port() == 'github.com'
Exemple #17
0
 def test_with_password_adds_password(self):
     assert (Netloc('*****@*****.**').with_password('1234') ==
             'zack:[email protected]')
Exemple #18
0
 def test_with_password_replaces_password(self):
     assert (Netloc('zack:[email protected]:443').with_password('5678') ==
             'zack:[email protected]:443')
Exemple #19
0
 def test_hostname(self):
     assert Netloc('zack:[email protected]:443').hostname == 'github.com'
Exemple #20
0
 def test_with_password_on_a_netloc_with_no_username_raises_ValueError(self):
     assert_raises(ValueError,
                   lambda: Netloc('github.com').with_password('1234'))
Exemple #21
0
 def test_port(self):
     assert Netloc('github.com:443').port == 443
     assert Netloc('github.com').port is None
Exemple #22
0
 def test_with_port_adds_port(self):
     assert Netloc('github.com').with_port(443) == 'github.com:443'