#NEWLINE# @ patch ( 'salt.modules.pip._get_cached_requirements' ) #NEWLINE# def test_install_multiple_requirements_arguments_in_resulting_command( self , get_cached_requirements ) : #NEWLINE# #INDENT# cached_reqs = [ 'my_cached_reqs-1' , 'my_cached_reqs-2' ] #NEWLINE# get_cached_requirements . side_effect = cached_reqs #NEWLINE# requirements = [ 'salt://requirements-1.txt' , 'salt://requirements-2.txt' ] #NEWLINE# expected = [ 'pip' , 'install' ] #NEWLINE# for item in cached_reqs : #NEWLINE# #INDENT# expected . extend ( [ '--requirement' , item ] ) #NEWLINE# #UNINDENT# mock = MagicMock ( return_value = { #NEWLINE# #INDENT# 'retcode' : 0 , #NEWLINE# 'stdout' : '' , #NEWLINE# #UNINDENT# } ) #NEWLINE# with patch . dict ( pip . __salt__ , { #NEWLINE# #INDENT# 'cmd.run_all' : mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# pip . install ( requirements = self ) #NEWLINE# mock . assert_called_once_with ( expected , saltenv = 'base' , runas = None , use_vt = False , python_shell = False ) #NEWLINE# #UNINDENT# get_cached_requirements . side_effect = cached_reqs #NEWLINE# mock = MagicMock ( return_value = { #NEWLINE# #INDENT# 'retcode' : 0 , #NEWLINE# 'stdout' : '' , #NEWLINE# #UNINDENT# } ) #NEWLINE# with patch . dict ( pip . __salt__ , { #NEWLINE# #INDENT# 'cmd.run_all' : mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# pip . install ( requirements = ',' . join ( requirements ) ) #NEWLINE# mock . assert_called_once_with ( expected , saltenv = 'base' , runas = None , use_vt = False , python_shell = False ) #NEWLINE# #UNINDENT# get_cached_requirements . side_effect = [ cached_reqs [ 0 ] ] #NEWLINE# mock = MagicMock ( return_value = { #NEWLINE# #INDENT# 'retcode' : 0 , #NEWLINE# 'stdout' : '' , #NEWLINE# #UNINDENT# } ) #NEWLINE# with patch . dict ( pip . __salt__ , { #NEWLINE# #INDENT# 'cmd.run_all' : mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# pip . install ( requirements = requirements [ 0 ] ) #NEWLINE# mock . assert_called_once_with ( [ 'pip' , 'install' , '--requirement' , cached_reqs [ 0 ] ] , saltenv = 'base' , runas = None , use_vt = False , python_shell = False )