#NEWLINE# @ requires_network ( ) #NEWLINE# @ destructiveTest #NEWLINE# def test_hold_unhold( self ) : #NEWLINE# #INDENT# '\n        test holding and unholding a package\n        ' #NEWLINE# pkg = 'htop' #NEWLINE# os_family = self . run_function ( 'grains.item' , [ 'os_family' ] ) [ 'os_family' ] #NEWLINE# os_major_release = self . run_function ( 'grains.item' , [ 'osmajorrelease' ] ) [ 'osmajorrelease' ] #NEWLINE# available = self . run_function ( 'sys.doc' , [ 'pkg.hold' ] ) #NEWLINE# if ( os_family == 'RedHat' ) : #NEWLINE# #INDENT# if ( os_major_release == '5' ) : #NEWLINE# #INDENT# self . skipTest ( '`yum versionlock` does not seem to work on RHEL/CentOS 5' ) #NEWLINE# #UNINDENT# #UNINDENT# if available : #NEWLINE# #INDENT# if ( os_family == 'RedHat' ) : #NEWLINE# #INDENT# lock_pkg = ( 'yum-versionlock' if ( os_major_release == '5' ) else 'yum-plugin-versionlock' ) #NEWLINE# versionlock = self . run_function ( 'pkg.version' , [ lock_pkg ] ) #NEWLINE# if ( not versionlock ) : #NEWLINE# #INDENT# self . run_function ( 'pkg.install' , [ lock_pkg ] ) #NEWLINE# #UNINDENT# #UNINDENT# hold_ret = self . run_function ( 'pkg.hold' , [ pkg ] ) #NEWLINE# self . assertIn ( pkg , hold_ret ) #NEWLINE# self . assertTrue ( hold_ret [ pkg ] [ 'result' ] ) #NEWLINE# unhold_ret = self . run_function ( 'pkg.unhold' , [ pkg ] ) #NEWLINE# self . assertIn ( pkg , unhold_ret ) #NEWLINE# self . assertTrue ( hold_ret [ pkg ] [ 'result' ] ) #NEWLINE# if ( os_family == 'RedHat' ) : #NEWLINE# #INDENT# if ( not versionlock ) : #NEWLINE# #INDENT# self . run_function ( 'pkg.remove' , [ lock_pkg ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# os_grain = self . run_function ( 'grains.item' , [ 'os' ] ) [ 'os' ] #NEWLINE# self . skipTest ( '{0} is unavailable on {1}' . format ( 'pkg.hold' , os_grain ) )