예제 #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'
예제 #2
0
 def test_netrc_success(self, MockOsPath):
   with patch('pants.backend.authentication.netrc_util.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()
예제 #3
0
 def test_netrc_success(self, MockOsPath):
     with patch("pants.backend.authentication.netrc_util.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()
예제 #4
0
 def netrc(self, netrc_contents):
     m = mock_open(read_data=netrc_contents)
     with patch('__builtin__.open', m):
         netrc = Netrc()
         yield netrc
예제 #5
0
 def test_netrc_file_missing_error(self, MockOsPath):
     MockOsPath.exists.return_value = False
     netrc = Netrc()
     with pytest.raises(netrc.NetrcError) as exc:
         netrc._ensure_loaded()
     assert exc.value.message == 'A ~/.netrc file is required to authenticate'
예제 #6
0
 def test_netrc_file_missing_error(self, MockOsPath):
   MockOsPath.exists.return_value = False
   netrc = Netrc()
   with pytest.raises(netrc.NetrcError) as exc:
     netrc._ensure_loaded()
   assert str(exc.value) == 'A ~/.netrc file is required to authenticate'