<s> """<STR_LIT>""" <EOL> from oslo_utils import importutils <EOL> from nova . compute import power_state <EOL> import nova . conf <EOL> from nova import context <EOL> from nova import objects <EOL> from nova . objects import instance as instance_obj <EOL> from nova . tests . unit . compute import eventlet_utils <EOL> from nova . tests . unit import fake_instance <EOL> from nova . tests . unit . virt . xenapi import stubs <EOL> from nova . virt . xenapi import vm_utils <EOL> CONF = nova . conf . CONF <EOL> CONF . import_opt ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class ComputeXenTestCase ( stubs . XenAPITestBaseNoDB ) : <EOL> def setUp ( self ) : <EOL> super ( ComputeXenTestCase , self ) . setUp ( ) <EOL> self . flags ( compute_driver = '<STR_LIT>' ) <EOL> self . flags ( connection_url = '<STR_LIT>' , <EOL> connection_password = '<STR_LIT>' , <EOL> group = '<STR_LIT>' ) <EOL> stubs . stubout_session ( self . stubs , stubs . FakeSessionForVMTests ) <EOL> self . compute = importutils . import_object ( CONF . compute_manager ) <EOL> self . compute . _sync_power_pool = eventlet_utils . SyncPool ( ) <EOL> def test_sync_power_states_instance_not_found ( self ) : <EOL> db_instance = fake_instance . fake_db_instance ( ) <EOL> ctxt = context . get_admin_context ( ) <EOL> instance_list = instance_obj . _make_instance_list ( ctxt , <EOL> objects . InstanceList ( ) , [ db_instance ] , None ) <EOL> instance = instance_list [ <NUM_LIT:0> ] <EOL> self . mox . StubOutWithMock ( objects . InstanceList , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . compute . driver , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( vm_utils , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . compute , '<STR_LIT>' ) <EOL> objects . InstanceList . get_by_host ( ctxt , <EOL> self . compute . host , expected_attrs = [ ] , <EOL> use_slave = True ) . AndReturn ( instance_list ) <EOL> self . compute . driver . get_num_instances ( ) . AndReturn ( <NUM_LIT:1> ) <EOL> vm_utils . lookup ( self . compute . driver . _session , instance [ '<STR_LIT:name>' ] , <EOL> False ) . AndReturn ( None ) <EOL> self . compute . _sync_instance_power_state ( ctxt , instance , <EOL> power_state . NOSTATE ) <EOL> self . mox . ReplayAll ( ) <EOL> self . compute . _sync_power_states ( ctxt ) </s>
