def test_chgid(self): ''' tests to change the gid for a named group ''' mock = MagicMock(return_value=1) with patch.dict(pw_group.__salt__, {'file.group_to_gid': mock}): self.assertTrue(pw_group.chgid('name', 1)) mock = MagicMock(side_effect=[1, 0]) with patch.dict(pw_group.__salt__, {'file.group_to_gid': mock}): mock = MagicMock(return_value=None) with patch.dict(pw_group.__salt__, {'cmd.run': mock}): self.assertTrue(pw_group.chgid('name', 0)) mock = MagicMock(side_effect=[1, 1]) with patch.dict(pw_group.__salt__, {'file.group_to_gid': mock}): mock = MagicMock(return_value=None) with patch.dict(pw_group.__salt__, {'cmd.run': mock}): self.assertFalse(pw_group.chgid('name', 0))
def test_chgid(): """ tests to change the gid for a named group """ mock = MagicMock(return_value=1) with patch.dict(pw_group.__salt__, {"file.group_to_gid": mock}): assert pw_group.chgid("name", 1) mock = MagicMock(side_effect=[1, 0]) with patch.dict(pw_group.__salt__, {"file.group_to_gid": mock}): mock = MagicMock(return_value=None) with patch.dict(pw_group.__salt__, {"cmd.run": mock}): assert pw_group.chgid("name", 0) mock = MagicMock(side_effect=[1, 1]) with patch.dict(pw_group.__salt__, {"file.group_to_gid": mock}): mock = MagicMock(return_value=None) with patch.dict(pw_group.__salt__, {"cmd.run": mock}): assert not pw_group.chgid("name", 0)