#NEWLINE# def test_script_validator( self ) : #NEWLINE# #INDENT# cls = images . SaharaScriptValidator #NEWLINE# env_map = { #NEWLINE# #INDENT# 'SIV_DISTRO' : 'centos' , #NEWLINE# #UNINDENT# } #NEWLINE# map_rep = 'export SIV_DISTRO=centos\n' #NEWLINE# cmd = "It's dangerous to go alone. Run this." #NEWLINE# expected_cmd = ( 'bash <<_SIV_\n%s\n_SIV_' % cmd ) #NEWLINE# validator = cls ( cmd , env_vars = env_map . keys ( ) , output_var = 'SIV_DISTRO' ) #NEWLINE# remote = mock . Mock ( execute_command = mock . Mock ( return_value = ( 0 , 'fedora' ) ) ) #NEWLINE# validator . validate ( remote , reconcile = True , env_map = env_map ) #NEWLINE# call = [ mock . call ( ( map_rep + expected_cmd ) , run_as_root = True ) ] #NEWLINE# remote . execute_command . assert_has_calls ( call ) #NEWLINE# self . assertEqual ( env_map [ 'SIV_DISTRO' ] , 'fedora' )