<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 lvs_service <EOL> lvs_service . __salt__ = { } <EOL> lvs_service . __opts__ = { } <EOL> @ skipIf ( NO_MOCK , NO_MOCK_REASON ) <EOL> class LvsServiceTestCase ( TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def test_present ( self ) : <EOL> '''<STR_LIT>''' <EOL> name = '<STR_LIT>' <EOL> ret = { '<STR_LIT:name>' : name , <EOL> '<STR_LIT:result>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { } } <EOL> mock_check = MagicMock ( side_effect = [ True , True , True , False , True , <EOL> False , True , False , False , False , <EOL> False ] ) <EOL> mock_edit = MagicMock ( side_effect = [ True , False ] ) <EOL> mock_add = MagicMock ( side_effect = [ True , False ] ) <EOL> with patch . dict ( lvs_service . __salt__ , { '<STR_LIT>' : mock_check , <EOL> '<STR_LIT>' : mock_edit , <EOL> '<STR_LIT>' : mock_add } ) : <EOL> with patch . dict ( lvs_service . __opts__ , { '<STR_LIT:test>' : True } ) : <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt } ) <EOL> self . assertDictEqual ( lvs_service . present ( name ) , ret ) <EOL> comt = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : None } ) <EOL> self . assertDictEqual ( lvs_service . present ( name ) , ret ) <EOL> with patch . dict ( lvs_service . __opts__ , { '<STR_LIT:test>' : False } ) : <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : True , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } } ) <EOL> self . assertDictEqual ( lvs_service . present ( name ) , ret ) <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : False , '<STR_LIT>' : { } } ) <EOL> self . assertDictEqual ( lvs_service . present ( name ) , ret ) <EOL> with patch . dict ( lvs_service . __opts__ , { '<STR_LIT:test>' : True } ) : <EOL> comt = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : None } ) <EOL> self . assertDictEqual ( lvs_service . present ( name ) , ret ) <EOL> with patch . dict ( lvs_service . __opts__ , { '<STR_LIT:test>' : False } ) : <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : True , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } } ) <EOL> self . assertDictEqual ( lvs_service . present ( name ) , ret ) <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : False , '<STR_LIT>' : { } } ) <EOL> self . assertDictEqual ( lvs_service . present ( name ) , ret ) <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>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { } } <EOL> mock_check = MagicMock ( side_effect = [ True , True , True , False ] ) <EOL> mock_delete = MagicMock ( side_effect = [ True , False ] ) <EOL> with patch . dict ( lvs_service . __salt__ , <EOL> { '<STR_LIT>' : mock_check , <EOL> '<STR_LIT>' : mock_delete } ) : <EOL> with patch . dict ( lvs_service . __opts__ , { '<STR_LIT:test>' : True } ) : <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt } ) <EOL> self . assertDictEqual ( lvs_service . absent ( name ) , ret ) <EOL> with patch . dict ( lvs_service . __opts__ , { '<STR_LIT:test>' : False } ) : <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : True , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } } ) <EOL> self . assertDictEqual ( lvs_service . absent ( name ) , ret ) <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : False , '<STR_LIT>' : { } } ) <EOL> self . assertDictEqual ( lvs_service . absent ( name ) , ret ) <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : True } ) <EOL> self . assertDictEqual ( lvs_service . absent ( name ) , ret ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from integration import run_tests <EOL> run_tests ( LvsServiceTestCase , needs_daemon = False ) </s>
