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'
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()
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()
def netrc(self, netrc_contents): m = mock_open(read_data=netrc_contents) with patch('__builtin__.open', m): netrc = Netrc() yield netrc
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'
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'