<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> import os <EOL> from salttesting import skipIf , TestCase <EOL> from salttesting . mock import ( <EOL> NO_MOCK , <EOL> NO_MOCK_REASON , <EOL> MagicMock , <EOL> mock_open , <EOL> patch ) <EOL> from salttesting . helpers import ensure_in_syspath <EOL> ensure_in_syspath ( '<STR_LIT>' ) <EOL> from salt . states import virt <EOL> import salt . utils <EOL> virt . __salt__ = { } <EOL> virt . __opts__ = { } <EOL> @ skipIf ( NO_MOCK , NO_MOCK_REASON ) <EOL> class LibvirtTestCase ( TestCase ) : <EOL> '''<STR_LIT>''' <EOL> @ skipIf ( os . geteuid ( ) != <NUM_LIT:0> , '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , MagicMock ( return_value = False ) ) <EOL> def test_keys ( 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 = MagicMock ( side_effect = [ [ ] , [ '<STR_LIT>' ] , <EOL> { '<STR_LIT>' : '<STR_LIT:A>' } ] ) <EOL> with patch . dict ( virt . __salt__ , { '<STR_LIT>' : mock } ) : <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt } ) <EOL> self . assertDictEqual ( virt . keys ( name ) , ret ) <EOL> with patch . dict ( virt . __opts__ , { '<STR_LIT:test>' : True } ) : <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : None } ) <EOL> self . assertDictEqual ( virt . keys ( name ) , ret ) <EOL> with patch . dict ( virt . __opts__ , { '<STR_LIT:test>' : False } ) : <EOL> with patch . object ( salt . utils , '<STR_LIT>' , MagicMock ( mock_open ( ) ) ) : <EOL> comt = ( '<STR_LIT>' ) <EOL> ret . update ( { '<STR_LIT>' : comt , '<STR_LIT:result>' : True , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } } ) <EOL> self . assertDictEqual ( virt . keys ( name ) , ret ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from integration import run_tests <EOL> run_tests ( LibvirtTestCase , needs_daemon = False ) </s>
