<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 portage_config <EOL> portage_config . __salt__ = { } <EOL> portage_config . __opts__ = { '<STR_LIT:test>' : True } <EOL> @ skipIf ( NO_MOCK , NO_MOCK_REASON ) <EOL> class PortageConfigTestCase ( TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def test_mod_init ( self ) : <EOL> '''<STR_LIT>''' <EOL> name = '<STR_LIT>' <EOL> mock = MagicMock ( side_effect = [ True , Exception ] ) <EOL> with patch . dict ( portage_config . __salt__ , <EOL> { '<STR_LIT>' : mock } ) : <EOL> self . assertTrue ( portage_config . mod_init ( name ) ) <EOL> self . assertFalse ( portage_config . mod_init ( name ) ) <EOL> @ patch ( '<STR_LIT>' , MagicMock ( return_value = '<STR_LIT>' ) ) <EOL> def test_flags ( self ) : <EOL> '''<STR_LIT>''' <EOL> name = '<STR_LIT>' <EOL> ret = { '<STR_LIT:name>' : name , <EOL> '<STR_LIT:result>' : False , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { } } <EOL> mock = MagicMock ( side_effect = Exception ( '<STR_LIT:error>' ) ) <EOL> with patch . dict ( portage_config . __salt__ , <EOL> { '<STR_LIT>' : mock } ) : <EOL> self . assertDictEqual ( portage_config . flags ( name , use = '<STR_LIT>' ) , ret ) <EOL> self . assertDictEqual ( portage_config . flags ( name , <EOL> accept_keywords = True ) , <EOL> ret ) <EOL> self . assertDictEqual ( portage_config . flags ( name , env = True ) , ret ) <EOL> self . assertDictEqual ( portage_config . flags ( name , license = True ) , ret ) <EOL> self . assertDictEqual ( portage_config . flags ( name , properties = True ) , <EOL> ret ) <EOL> self . assertDictEqual ( portage_config . flags ( name , mask = True ) , ret ) <EOL> self . assertDictEqual ( portage_config . flags ( name , unmask = True ) , ret ) <EOL> ret . update ( { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:result>' : True } ) <EOL> self . assertDictEqual ( portage_config . flags ( name ) , ret ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from integration import run_tests <EOL> run_tests ( PortageConfigTestCase , needs_daemon = False ) </s>
