def test_rename(self): """ Change the username for a named user """ mock = MagicMock(return_value=False) with patch.object(pw_user, "info", mock): self.assertRaises(CommandExecutionError, pw_user.rename, "name", 1) mock = MagicMock(return_value=True) with patch.object(pw_user, "info", mock): self.assertRaises(CommandExecutionError, pw_user.rename, "name", 1) mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {"cmd.run": mock}): mock = MagicMock(side_effect=[{ "name": "" }, False, { "name": "name" }]) with patch.object(pw_user, "info", mock): self.assertTrue(pw_user.rename("name", "name")) mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {"cmd.run": mock}): mock = MagicMock(side_effect=[{"name": ""}, False, {"name": ""}]) with patch.object(pw_user, "info", mock): self.assertFalse(pw_user.rename("name", "name"))
def test_rename(self): ''' Change the username for a named user ''' mock = MagicMock(return_value=False) with patch.object(pw_user, 'info', mock): self.assertRaises(CommandExecutionError, pw_user.rename, 'name', 1) mock = MagicMock(return_value=True) with patch.object(pw_user, 'info', mock): self.assertRaises(CommandExecutionError, pw_user.rename, 'name', 1) mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {'cmd.run': mock}): mock = MagicMock(side_effect=[{ 'name': '' }, False, { 'name': 'name' }]) with patch.object(pw_user, 'info', mock): self.assertTrue(pw_user.rename('name', 'name')) mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {'cmd.run': mock}): mock = MagicMock(side_effect=[{'name': ''}, False, {'name': ''}]) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.rename('name', 'name'))
def test_rename(self): ''' Change the username for a named user ''' mock = MagicMock(return_value=False) with patch.object(pw_user, 'info', mock): self.assertRaises(CommandExecutionError, pw_user.rename, 'name', 1) mock = MagicMock(return_value=True) with patch.object(pw_user, 'info', mock): self.assertRaises(CommandExecutionError, pw_user.rename, 'name', 1) mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {'cmd.run': mock}): mock = MagicMock(side_effect=[{'name': ''}, False, {'name': 'name'}]) with patch.object(pw_user, 'info', mock): self.assertTrue(pw_user.rename('name', 'name')) mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {'cmd.run': mock}): mock = MagicMock(side_effect=[{'name': ''}, False, {'name': ''}]) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.rename('name', 'name'))