<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> import os <EOL> from salttesting import skipIf <EOL> from salttesting . helpers import ( <EOL> destructiveTest , <EOL> ensure_in_syspath , <EOL> requires_system_grains <EOL> ) <EOL> ensure_in_syspath ( '<STR_LIT>' ) <EOL> import integration <EOL> import salt . utils <EOL> from salt . exceptions import CommandExecutionError <EOL> ADD_PKG = '<STR_LIT>' <EOL> DEL_PKG = '<STR_LIT>' <EOL> class BrewModuleTest ( integration . ModuleCase ) : <EOL> '''<STR_LIT>''' <EOL> def setUp ( self ) : <EOL> '''<STR_LIT>''' <EOL> os_grain = self . run_function ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> brew = salt . utils . which ( '<STR_LIT>' ) <EOL> if os_grain [ '<STR_LIT>' ] not in '<STR_LIT>' : <EOL> self . skipTest ( <EOL> '<STR_LIT>' . format ( <EOL> ** os_grain <EOL> ) <EOL> ) <EOL> if not brew : <EOL> self . skipTest ( <EOL> '<STR_LIT>' <EOL> ) <EOL> @ destructiveTest <EOL> @ skipIf ( os . geteuid ( ) != <NUM_LIT:0> , '<STR_LIT>' ) <EOL> @ requires_system_grains <EOL> def test_brew_install ( self , grains = None ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> self . run_function ( '<STR_LIT>' , [ ADD_PKG ] ) <EOL> pkg_list = self . run_function ( '<STR_LIT>' ) <EOL> try : <EOL> self . assertIn ( ADD_PKG , pkg_list ) <EOL> except AssertionError : <EOL> self . run_function ( '<STR_LIT>' , [ ADD_PKG ] ) <EOL> raise <EOL> except CommandExecutionError : <EOL> self . run_function ( '<STR_LIT>' , [ ADD_PKG ] ) <EOL> raise <EOL> @ destructiveTest <EOL> @ skipIf ( os . geteuid ( ) != <NUM_LIT:0> , '<STR_LIT>' ) <EOL> @ requires_system_grains <EOL> def test_remove ( self , grains = None ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> self . run_function ( '<STR_LIT>' , [ DEL_PKG ] ) <EOL> pkg_list = self . run_function ( '<STR_LIT>' ) <EOL> if DEL_PKG not in pkg_list : <EOL> self . run_function ( '<STR_LIT>' , [ DEL_PKG ] ) <EOL> self . skipTest ( '<STR_LIT>' ) <EOL> self . run_function ( '<STR_LIT>' , [ DEL_PKG ] ) <EOL> del_list = self . run_function ( '<STR_LIT>' ) <EOL> try : <EOL> self . assertNotIn ( DEL_PKG , del_list ) <EOL> except AssertionError : <EOL> raise <EOL> except CommandExecutionError : <EOL> self . run_function ( '<STR_LIT>' , [ DEL_PKG ] ) <EOL> raise <EOL> @ destructiveTest <EOL> @ skipIf ( os . geteuid ( ) != <NUM_LIT:0> , '<STR_LIT>' ) <EOL> @ requires_system_grains <EOL> def test_mac_brew_pkg_version ( self , grains = None ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> self . run_function ( '<STR_LIT>' , [ ADD_PKG ] ) <EOL> pkg_list = self . run_function ( '<STR_LIT>' ) <EOL> version = self . run_function ( '<STR_LIT>' , [ ADD_PKG ] ) <EOL> try : <EOL> self . assertTrue ( version , <EOL> msg = ( '<STR_LIT>' . format ( version ) ) ) <EOL> self . assertIn ( ADD_PKG , pkg_list , <EOL> msg = ( '<STR_LIT>' <EOL> . format ( ADD_PKG , pkg_list ) ) ) <EOL> self . assertIn ( version , str ( pkg_list [ ADD_PKG ] ) , <EOL> msg = ( '<STR_LIT>' <EOL> . format ( ADD_PKG , version , pkg_list [ ADD_PKG ] ) ) ) <EOL> except AssertionError : <EOL> self . run_function ( '<STR_LIT>' , [ ADD_PKG ] ) <EOL> raise <EOL> except CommandExecutionError : <EOL> self . run_function ( '<STR_LIT>' , [ ADD_PKG ] ) <EOL> raise <EOL> @ destructiveTest <EOL> @ skipIf ( os . geteuid ( ) != <NUM_LIT:0> , '<STR_LIT>' ) <EOL> @ requires_system_grains <EOL> def test_mac_brew_refresh_db ( self , grains = None ) : <EOL> '''<STR_LIT>''' <EOL> refresh_brew = self . run_function ( '<STR_LIT>' ) <EOL> self . assertTrue ( refresh_brew ) <EOL> @ destructiveTest <EOL> @ skipIf ( os . geteuid ( ) != <NUM_LIT:0> , '<STR_LIT>' ) <EOL> @ requires_system_grains <EOL> def tearDown ( self , grains = None ) : <EOL> '''<STR_LIT>''' <EOL> pkg_list = self . run_function ( '<STR_LIT>' ) <EOL> if ADD_PKG in pkg_list : <EOL> self . run_function ( '<STR_LIT>' , [ ADD_PKG ] ) <EOL> if DEL_PKG in pkg_list : <EOL> self . run_function ( '<STR_LIT>' , [ DEL_PKG ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from integration import run_tests <EOL> run_tests ( BrewModuleTest ) </s>
