<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> from salttesting import TestCase , skipIf <EOL> from salttesting . mock import ( <EOL> MagicMock , <EOL> patch , <EOL> NO_MOCK , <EOL> NO_MOCK_REASON <EOL> ) <EOL> from salttesting . helpers import ensure_in_syspath <EOL> ensure_in_syspath ( '<STR_LIT>' ) <EOL> from salt . modules import pyenv <EOL> pyenv . __grains__ = { } <EOL> pyenv . __salt__ = { } <EOL> @ skipIf ( NO_MOCK , NO_MOCK_REASON ) <EOL> class PyenvTestCase ( TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def test_install ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_opt = MagicMock ( return_value = '<STR_LIT>' ) <EOL> mock_ret = MagicMock ( return_value = <NUM_LIT:0> ) <EOL> with patch . dict ( pyenv . __salt__ , { '<STR_LIT>' : mock_opt , <EOL> '<STR_LIT>' : mock_ret } ) : <EOL> self . assertTrue ( pyenv . install ( ) ) <EOL> def test_update ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_opt = MagicMock ( return_value = '<STR_LIT>' ) <EOL> with patch . dict ( pyenv . __salt__ , { '<STR_LIT>' : mock_opt } ) : <EOL> self . assertFalse ( pyenv . update ( ) ) <EOL> def test_is_installed ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_cmd = MagicMock ( return_value = True ) <EOL> mock_opt = MagicMock ( return_value = '<STR_LIT>' ) <EOL> with patch . dict ( pyenv . __salt__ , { '<STR_LIT>' : mock_opt , <EOL> '<STR_LIT>' : mock_cmd } ) : <EOL> self . assertTrue ( pyenv . is_installed ( ) ) <EOL> def test_install_python ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_opt = MagicMock ( return_value = '<STR_LIT>' ) <EOL> mock_cmd = MagicMock ( return_value = True ) <EOL> mock_all = MagicMock ( return_value = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:error>' } ) <EOL> with patch . dict ( pyenv . __grains__ , { '<STR_LIT>' : '<STR_LIT>' } ) : <EOL> mock_all = MagicMock ( return_value = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:error>' } ) <EOL> with patch . dict ( pyenv . __salt__ , { '<STR_LIT>' : mock_opt , <EOL> '<STR_LIT>' : mock_cmd , <EOL> '<STR_LIT>' : mock_all } ) : <EOL> self . assertEqual ( pyenv . install_python ( '<STR_LIT>' ) , '<STR_LIT:error>' ) <EOL> mock_all = MagicMock ( return_value = { '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:error>' } ) <EOL> with patch . dict ( pyenv . __salt__ , { '<STR_LIT>' : mock_opt , <EOL> '<STR_LIT>' : mock_cmd , <EOL> '<STR_LIT>' : mock_all } ) : <EOL> self . assertFalse ( pyenv . install_python ( '<STR_LIT>' ) ) <EOL> def test_uninstall_python ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_opt = MagicMock ( return_value = '<STR_LIT>' ) <EOL> mock_cmd = MagicMock ( return_value = True ) <EOL> mock_all = MagicMock ( return_value = { '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:error>' } ) <EOL> with patch . dict ( pyenv . __salt__ , { '<STR_LIT>' : mock_cmd , <EOL> '<STR_LIT>' : mock_opt , <EOL> '<STR_LIT>' : mock_all } ) : <EOL> self . assertTrue ( pyenv . uninstall_python ( '<STR_LIT>' ) ) <EOL> def test_versions ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_opt = MagicMock ( return_value = '<STR_LIT>' ) <EOL> mock_cmd = MagicMock ( return_value = True ) <EOL> mock_all = MagicMock ( return_value = { '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:error>' } ) <EOL> with patch . dict ( pyenv . __salt__ , { '<STR_LIT>' : mock_cmd , <EOL> '<STR_LIT>' : mock_opt , <EOL> '<STR_LIT>' : mock_all } ) : <EOL> self . assertListEqual ( pyenv . versions ( ) , [ ] ) <EOL> def test_default ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_opt = MagicMock ( return_value = '<STR_LIT>' ) <EOL> mock_cmd = MagicMock ( return_value = True ) <EOL> mock_all = MagicMock ( return_value = { '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:error>' } ) <EOL> with patch . dict ( pyenv . __salt__ , { '<STR_LIT>' : mock_cmd , <EOL> '<STR_LIT>' : mock_opt , <EOL> '<STR_LIT>' : mock_all } ) : <EOL> self . assertEqual ( pyenv . default ( ) , '<STR_LIT>' ) <EOL> self . assertTrue ( pyenv . default ( '<STR_LIT>' ) ) <EOL> def test_list ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_opt = MagicMock ( return_value = '<STR_LIT>' ) <EOL> mock_cmd = MagicMock ( return_value = True ) <EOL> mock_all = MagicMock ( return_value = { '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:error>' } ) <EOL> with patch . dict ( pyenv . __salt__ , { '<STR_LIT>' : mock_cmd , <EOL> '<STR_LIT>' : mock_opt , <EOL> '<STR_LIT>' : mock_all } ) : <EOL> self . assertListEqual ( pyenv . list_ ( ) , [ ] ) <EOL> def test_rehash ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_opt = MagicMock ( return_value = '<STR_LIT>' ) <EOL> mock_cmd = MagicMock ( return_value = True ) <EOL> mock_all = MagicMock ( return_value = { '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:error>' } ) <EOL> with patch . dict ( pyenv . __salt__ , { '<STR_LIT>' : mock_cmd , <EOL> '<STR_LIT>' : mock_opt , <EOL> '<STR_LIT>' : mock_all } ) : <EOL> self . assertTrue ( pyenv . rehash ( ) ) <EOL> def test_do ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_opt = MagicMock ( return_value = '<STR_LIT>' ) <EOL> mock_cmd = MagicMock ( return_value = True ) <EOL> mock_all = MagicMock ( return_value = { '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:error>' } ) <EOL> with patch . dict ( pyenv . __salt__ , { '<STR_LIT>' : mock_cmd , <EOL> '<STR_LIT>' : mock_opt , <EOL> '<STR_LIT>' : mock_all } ) : <EOL> self . assertFalse ( pyenv . do ( '<STR_LIT>' ) ) <EOL> mock_all = MagicMock ( return_value = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:error>' } ) <EOL> with patch . dict ( pyenv . __salt__ , { '<STR_LIT>' : mock_opt , <EOL> '<STR_LIT>' : mock_cmd , <EOL> '<STR_LIT>' : mock_all } ) : <EOL> self . assertEqual ( pyenv . do ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_do_with_python ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_opt = MagicMock ( return_value = '<STR_LIT>' ) <EOL> mock_cmd = MagicMock ( return_value = True ) <EOL> mock_all = MagicMock ( return_value = { '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:error>' } ) <EOL> with patch . dict ( pyenv . __salt__ , { '<STR_LIT>' : mock_cmd , <EOL> '<STR_LIT>' : mock_opt , <EOL> '<STR_LIT>' : mock_all } ) : <EOL> self . assertFalse ( pyenv . do_with_python ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from integration import run_tests <EOL> run_tests ( PyenvTestCase , needs_daemon = False ) </s>
