Esempio n. 1
0
 def test_netrc_file_missing_error(self, MockOsPath):
     MockOsPath.exists.return_value = False
     netrc = Netrc()
     with self.assertRaises(netrc.NetrcError) as exc:
         netrc._ensure_loaded()
     assert str(
         exc.exception) == 'A ~/.netrc file is required to authenticate'
Esempio n. 2
0
 def test_netrc_success(self, MockOsPath):
   with patch('pants.util.netrc.NetrcDb') as mock_netrc:
     instance = mock_netrc.return_value
     instance.hosts = {'host': ('user', 'user', 'passw0rd')}
     instance.authenticators.return_value = ('user', 'user', 'passw0rd')
     netrc = Netrc()
     netrc._ensure_loaded()
Esempio n. 3
0
 def test_netrc_success(self, MockOsPath):
     with patch('pants.util.netrc.NetrcDb') as mock_netrc:
         instance = mock_netrc.return_value
         instance.hosts = {'host': ('user', 'user', 'passw0rd')}
         instance.authenticators.return_value = ('user', 'user', 'passw0rd')
         netrc = Netrc()
         netrc._ensure_loaded()
Esempio n. 4
0
 def test_netrc_success(self, MockOsPath):
     with patch("pants.util.netrc.NetrcDb") as mock_netrc:
         instance = mock_netrc.return_value
         instance.hosts = {"host": ("user", "user", "passw0rd")}
         instance.authenticators.return_value = ("user", "user", "passw0rd")
         netrc = Netrc()
         netrc._ensure_loaded()
Esempio n. 5
0
 def test_netrc_file_missing_error(self, MockOsPath):
   MockOsPath.exists.return_value = False
   netrc = Netrc()
   with self.assertRaises(netrc.NetrcError) as exc:
     netrc._ensure_loaded()
   assert str(exc.exception) == 'A ~/.netrc file is required to authenticate'
Esempio n. 6
0
 def _credentials(self, repository):
     netrc = Netrc()
     return (netrc.getusername(repository), netrc.getpassword(repository))
Esempio n. 7
0
 def netrc(self, netrc_contents):
     m = mock_open(read_data=netrc_contents)
     with patch('__builtin__.open', m):
         netrc = Netrc()
         yield netrc
Esempio n. 8
0
 def _credentials(self, repository):
   netrc = Netrc()
   return (netrc.getusername(repository), netrc.getpassword(repository))
Esempio n. 9
0
 def netrc(self, netrc_contents):
     m = mock_open(read_data=netrc_contents)
     with patch("builtins.open", m):
         netrc = Netrc()
         yield netrc
Esempio n. 10
0
 def netrc(self, netrc_contents):
     m = mock_open(read_data=netrc_contents)
     open_builtin_name = 'builtins.open' if PY3 else '__builtin__.open'
     with patch(open_builtin_name, m):
         netrc = Netrc()
         yield netrc