def test_chshell(self): """ Test if shell given is same as previous shell """ mock = MagicMock(return_value={"shell": "A"}) with patch.object(pw_user, "info", mock): self.assertTrue(pw_user.chshell("name", "A")) mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {"cmd.run": mock}): mock = MagicMock(side_effect=[{"shell": "B"}, {"shell": "B"}]) with patch.object(pw_user, "info", mock): self.assertFalse(pw_user.chshell("name", "A")) mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {"cmd.run": mock}): mock = MagicMock(side_effect=[{"shell": "A"}, {"shell": "B"}]) with patch.object(pw_user, "info", mock): self.assertTrue(pw_user.chshell("name", "A"))
def test_chshell(self): ''' Test if shell given is same as previous shell ''' mock = MagicMock(return_value={'shell': 'A'}) with patch.object(pw_user, 'info', mock): self.assertTrue(pw_user.chshell('name', 'A')) mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {'cmd.run': mock}): mock = MagicMock(side_effect=[{'shell': 'B'}, {'shell': 'B'}]) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.chshell('name', 'A')) mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {'cmd.run': mock}): mock = MagicMock(side_effect=[{'shell': 'A'}, {'shell': 'B'}]) with patch.object(pw_user, 'info', mock): self.assertTrue(pw_user.chshell('name', 'A'))