<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> from salttesting import skipIf , TestCase <EOL> from salttesting . mock import ( <EOL> NO_MOCK , <EOL> NO_MOCK_REASON , <EOL> MagicMock , <EOL> patch ) <EOL> from salttesting . helpers import ensure_in_syspath <EOL> ensure_in_syspath ( '<STR_LIT>' ) <EOL> from salt . states import boto_asg <EOL> boto_asg . __salt__ = { } <EOL> boto_asg . __opts__ = { } <EOL> @ skipIf ( NO_MOCK , NO_MOCK_REASON ) <EOL> class BotoAsgTestCase ( TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def test_present ( self ) : <EOL> '''<STR_LIT>''' <EOL> name = '<STR_LIT>' <EOL> launch_config_name = '<STR_LIT>' <EOL> availability_zones = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> min_size = <NUM_LIT:1> <EOL> max_size = <NUM_LIT:1> <EOL> ret = { '<STR_LIT:name>' : name , <EOL> '<STR_LIT:result>' : None , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> mock = MagicMock ( side_effect = [ False , { '<STR_LIT>' : <NUM_LIT:2> } , [ '<STR_LIT>' ] ] ) <EOL> with patch . dict ( boto_asg . __salt__ , { '<STR_LIT>' : mock } ) : <EOL> with patch . dict ( boto_asg . __opts__ , { '<STR_LIT:test>' : True } ) : <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt } ) <EOL> with patch . dict ( boto_asg . __salt__ , <EOL> { '<STR_LIT>' : MagicMock ( return_value = { } ) } ) : <EOL> self . assertDictEqual ( <EOL> boto_asg . present ( <EOL> name , <EOL> launch_config_name , <EOL> availability_zones , <EOL> min_size , <EOL> max_size <EOL> ) , <EOL> ret <EOL> ) <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : None } ) <EOL> with patch . dict ( boto_asg . __salt__ , <EOL> { '<STR_LIT>' : MagicMock ( return_value = { } ) } ) : <EOL> self . assertDictEqual ( <EOL> boto_asg . present ( <EOL> name , <EOL> launch_config_name , <EOL> availability_zones , <EOL> min_size , <EOL> max_size <EOL> ) , <EOL> ret <EOL> ) <EOL> with patch . dict ( boto_asg . __salt__ , <EOL> { '<STR_LIT>' : MagicMock ( return_value = { } ) } ) : <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : True } ) <EOL> self . assertDictEqual ( <EOL> boto_asg . present ( <EOL> name , <EOL> launch_config_name , <EOL> availability_zones , <EOL> min_size , <EOL> max_size <EOL> ) , <EOL> ret <EOL> ) <EOL> def test_absent ( self ) : <EOL> '''<STR_LIT>''' <EOL> name = '<STR_LIT>' <EOL> ret = { '<STR_LIT:name>' : name , <EOL> '<STR_LIT:result>' : None , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> mock = MagicMock ( side_effect = [ True , False ] ) <EOL> with patch . dict ( boto_asg . __salt__ , { '<STR_LIT>' : mock } ) : <EOL> with patch . dict ( boto_asg . __opts__ , { '<STR_LIT:test>' : True } ) : <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt } ) <EOL> self . assertDictEqual ( boto_asg . absent ( name ) , ret ) <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : True } ) <EOL> self . assertDictEqual ( boto_asg . absent ( name ) , ret ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from integration import run_tests <EOL> run_tests ( BotoAsgTestCase , needs_daemon = False ) </s>
