#NEWLINE# def test_installed( self ) : #NEWLINE# #INDENT# '\n        Test to verify that the specified python is installed with pyenv.\n        ' #NEWLINE# name = 'python-2.7.6' #NEWLINE# ret = { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'result' : None , #NEWLINE# 'comment' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# with patch . dict ( pyenv . __opts__ , { #NEWLINE# #INDENT# 'test' : True , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# comt = 'python 2.7.6 is set to be installed' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( pyenv . installed ( name ) , ret ) #NEWLINE# #UNINDENT# with patch . dict ( pyenv . __opts__ , { #NEWLINE# #INDENT# 'test' : False , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# mock_f = MagicMock ( side_effect = [ False , False , True ] ) #NEWLINE# mock_fa = MagicMock ( side_effect = [ False , True ] ) #NEWLINE# mock_str = MagicMock ( return_value = '2.7.6' ) #NEWLINE# mock_lst = MagicMock ( return_value = [ '2.7.6' ] ) #NEWLINE# with patch . dict ( pyenv . __salt__ , { #NEWLINE# #INDENT# 'pyenv.is_installed' : mock_f , #NEWLINE# 'pyenv.install' : mock_fa , #NEWLINE# 'pyenv.default' : mock_str , #NEWLINE# 'pyenv.versions' : mock_lst , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# comt = 'pyenv failed to install' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# 'result' : False , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( pyenv . installed ( name ) , ret ) #NEWLINE# comt = 'Requested python exists.' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# 'result' : True , #NEWLINE# 'default' : True , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( pyenv . installed ( name ) , ret ) #NEWLINE# self . assertDictEqual ( pyenv . installed ( name ) , ret )