def test_install_rbenv(self): ''' Test to install rbenv if not installed. ''' name = 'myqueue' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} with patch.dict(rbenv.__opts__, {'test': True}): comt = ('Rbenv is set to be installed') ret.update({'comment': comt, 'result': None}) self.assertDictEqual(rbenv.install_rbenv(name), ret) with patch.dict(rbenv.__opts__, {'test': False}): mock = MagicMock(side_effect=[False, True]) with patch.dict(rbenv.__salt__, { 'rbenv.is_installed': mock, 'rbenv.install': mock }): comt = ('Rbenv installed') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(rbenv.install_rbenv(name), ret)
def test_install_rbenv(self): """ Test to install rbenv if not installed. """ name = "myqueue" ret = {"name": name, "changes": {}, "result": True, "comment": ""} mock_is = MagicMock(side_effect=[False, True, True, False, False]) mock_i = MagicMock(side_effect=[False, True]) with patch.dict(rbenv.__salt__, { "rbenv.is_installed": mock_is, "rbenv.install": mock_i }): with patch.dict(rbenv.__opts__, {"test": True}): comt = "Rbenv is set to be installed" ret.update({"comment": comt, "result": None}) self.assertDictEqual(rbenv.install_rbenv(name), ret) comt = "Rbenv is already installed" ret.update({"comment": comt, "result": True}) self.assertDictEqual(rbenv.install_rbenv(name), ret) with patch.dict(rbenv.__opts__, {"test": False}): comt = "Rbenv is already installed" ret.update({"comment": comt, "result": True}) self.assertDictEqual(rbenv.install_rbenv(name), ret) comt = "Rbenv failed to install" ret.update({"comment": comt, "result": False}) self.assertDictEqual(rbenv.install_rbenv(name), ret) comt = "Rbenv installed" ret.update({"comment": comt, "result": True}) self.assertDictEqual(rbenv.install_rbenv(name), ret)
def test_install_rbenv(self): ''' Test to install rbenv if not installed. ''' name = 'myqueue' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} with patch.dict(rbenv.__opts__, {'test': True}): comt = ('Rbenv is set to be installed') ret.update({'comment': comt, 'result': None}) self.assertDictEqual(rbenv.install_rbenv(name), ret) with patch.dict(rbenv.__opts__, {'test': False}): mock = MagicMock(side_effect=[False, True]) with patch.dict(rbenv.__salt__, {'rbenv.is_installed': mock, 'rbenv.install': mock}): comt = ('Rbenv installed') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(rbenv.install_rbenv(name), ret)