<s> from __future__ import absolute_import <EOL> import os <EOL> import textwrap <EOL> from salttesting . helpers import ensure_in_syspath <EOL> ensure_in_syspath ( '<STR_LIT>' ) <EOL> import integration <EOL> import salt . utils <EOL> STATE_DIR = os . path . join ( integration . FILES , '<STR_LIT:file>' , '<STR_LIT>' ) <EOL> class EnabledTest ( integration . ModuleCase ) : <EOL> '''<STR_LIT>''' <EOL> cmd = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def test_shell_default_enabled ( self ) : <EOL> '''<STR_LIT>''' <EOL> enabled_ret = '<STR_LIT>' <EOL> ret = self . run_function ( '<STR_LIT>' , [ self . cmd ] ) <EOL> self . assertEqual ( ret . strip ( ) , enabled_ret ) <EOL> def test_shell_disabled ( self ) : <EOL> '''<STR_LIT>''' <EOL> disabled_ret = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> ret = self . run_function ( '<STR_LIT>' , [ self . cmd ] , python_shell = False ) <EOL> self . assertEqual ( ret , disabled_ret ) <EOL> def test_template_default_enabled ( self ) : <EOL> '''<STR_LIT>''' <EOL> state_name = '<STR_LIT>' <EOL> state_filename = state_name + '<STR_LIT>' <EOL> state_file = os . path . join ( STATE_DIR , state_filename ) <EOL> enabled_ret = '<STR_LIT>' <EOL> ret_key = '<STR_LIT>' . format ( enabled_ret ) <EOL> try : <EOL> salt . utils . fopen ( state_file , '<STR_LIT:w>' ) . write ( textwrap . dedent ( '''<STR_LIT>''' . format ( self . cmd ) ) ) <EOL> ret = self . run_function ( '<STR_LIT>' , [ state_name ] ) <EOL> self . assertEqual ( ret [ ret_key ] [ '<STR_LIT:name>' ] , enabled_ret ) <EOL> finally : <EOL> os . remove ( state_file ) <EOL> def test_template_disabled ( self ) : <EOL> '''<STR_LIT>''' <EOL> state_name = '<STR_LIT>' <EOL> state_filename = state_name + '<STR_LIT>' <EOL> state_file = os . path . join ( STATE_DIR , state_filename ) <EOL> disabled_ret = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> ret_key = '<STR_LIT>' . format ( disabled_ret ) <EOL> try : <EOL> salt . utils . fopen ( state_file , '<STR_LIT:w>' ) . write ( textwrap . dedent ( '''<STR_LIT>''' . format ( self . cmd ) ) ) <EOL> ret = self . run_function ( '<STR_LIT>' , [ state_name ] ) <EOL> self . assertEqual ( ret [ ret_key ] [ '<STR_LIT:name>' ] , disabled_ret ) <EOL> finally : <EOL> os . remove ( state_file ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from integration import run_tests <EOL> run_tests ( EnabledTest ) </s>
