def test_do(self): """ Test if it execute a python command with pyenv's shims from the user or the system. """ mock_opt = MagicMock(return_value="salt stack") mock_cmd = MagicMock(return_value=True) mock_all = MagicMock( return_value={"retcode": True, "stdout": "salt", "stderr": "error"} ) with patch.dict( pyenv.__salt__, { "cmd.has_exec": mock_cmd, "config.option": mock_opt, "cmd.run_all": mock_all, }, ): self.assertFalse(pyenv.do("gem list bundler")) mock_all = MagicMock( return_value={"retcode": 0, "stdout": "salt", "stderr": "error"} ) with patch.dict( pyenv.__salt__, { "config.option": mock_opt, "cmd.has_exec": mock_cmd, "cmd.run_all": mock_all, }, ): self.assertEqual(pyenv.do("gem list bundler"), "salt")
def test_do(self): ''' Test if it execute a python command with pyenv's shims from the user or the system. ''' mock_opt = MagicMock(return_value='salt stack') mock_cmd = MagicMock(return_value=True) mock_all = MagicMock(return_value={ 'retcode': True, 'stdout': 'salt', 'stderr': 'error' }) with patch.dict( pyenv.__salt__, { 'cmd.has_exec': mock_cmd, 'config.option': mock_opt, 'cmd.run_all': mock_all }): self.assertFalse(pyenv.do('gem list bundler')) mock_all = MagicMock(return_value={ 'retcode': 0, 'stdout': 'salt', 'stderr': 'error' }) with patch.dict( pyenv.__salt__, { 'config.option': mock_opt, 'cmd.has_exec': mock_cmd, 'cmd.run_all': mock_all }): self.assertEqual(pyenv.do('gem list bundler'), 'salt')
def test_do(self): ''' Test if it execute a python command with pyenv's shims from the user or the system. ''' mock_opt = MagicMock(return_value='salt stack') mock_cmd = MagicMock(return_value=True) mock_all = MagicMock(return_value={'retcode': True, 'stdout': 'salt', 'stderr': 'error'}) with patch.dict(pyenv.__salt__, {'cmd.has_exec': mock_cmd, 'config.option': mock_opt, 'cmd.run_all': mock_all}): self.assertFalse(pyenv.do('gem list bundler')) mock_all = MagicMock(return_value={'retcode': 0, 'stdout': 'salt', 'stderr': 'error'}) with patch.dict(pyenv.__salt__, {'config.option': mock_opt, 'cmd.has_exec': mock_cmd, 'cmd.run_all': mock_all}): self.assertEqual(pyenv.do('gem list bundler'), 'salt')