def test_chgroups(self): """ Test if no group needs to be added """ mock = MagicMock(return_value=False) with patch.dict(pw_user.__salt__, {"cmd.retcode": mock}): mock = MagicMock(return_value=["a", "b", "c", "d"]) with patch.object(pw_user, "list_groups", mock): self.assertTrue(pw_user.chgroups("name", "a, b, c, d")) mock = MagicMock(return_value=False) with patch.dict(pw_user.__salt__, {"cmd.retcode": mock}): mock = MagicMock(return_value=["a", "b"]) with patch.object(pw_user, "list_groups", mock): self.assertTrue(pw_user.chgroups("name", "a, b, c"))
def test_chgroups(self): ''' Test if no group needs to be added ''' mock = MagicMock(return_value=False) with patch.dict(pw_user.__salt__, {'cmd.retcode': mock}): mock = MagicMock(return_value=['a', 'b', 'c', 'd']) with patch.object(pw_user, 'list_groups', mock): self.assertTrue(pw_user.chgroups('name', 'a, b, c, d')) mock = MagicMock(return_value=False) with patch.dict(pw_user.__salt__, {'cmd.retcode': mock}): mock = MagicMock(return_value=['a', 'b']) with patch.object(pw_user, 'list_groups', mock): self.assertTrue(pw_user.chgroups('name', 'a, b, c'))