def test_get_by_instance_uuid_no_entries(self):
     self.mox.StubOutWithMock(db, 'instance_info_cache_get')
     db.instance_info_cache_get(self.context, 'fake-uuid').AndReturn(None)
     self.mox.ReplayAll()
     self.assertRaises(
             exception.InstanceInfoCacheNotFound,
             instance_info_cache.InstanceInfoCache.get_by_instance_uuid,
             self.context, 'fake-uuid')
Beispiel #2
0
 def test_get_by_instance_uuid_no_entries(self):
     self.mox.StubOutWithMock(db, 'instance_info_cache_get')
     db.instance_info_cache_get(self.context, 'fake-uuid').AndReturn(None)
     self.mox.ReplayAll()
     self.assertRaises(
         exception.InstanceInfoCacheNotFound,
         instance_info_cache.InstanceInfoCache.get_by_instance_uuid,
         self.context, 'fake-uuid')
Beispiel #3
0
 def test_refresh(self):
     obj = instance_info_cache.InstanceInfoCache.new(
         self.context, 'fake-uuid1')
     self.mox.StubOutWithMock(db, 'instance_info_cache_get')
     db.instance_info_cache_get(self.context,
                                'fake-uuid1').AndReturn(fake_info_cache)
     self.mox.ReplayAll()
     obj.refresh()
     self.assertEqual(fake_info_cache['instance_uuid'], obj.instance_uuid)
 def test_refresh(self):
     obj = instance_info_cache.InstanceInfoCache.new(self.context,
                                                     'fake-uuid1')
     self.mox.StubOutWithMock(db, 'instance_info_cache_get')
     db.instance_info_cache_get(self.context, 'fake-uuid1').AndReturn(
         fake_info_cache)
     self.mox.ReplayAll()
     obj.refresh()
     self.assertEqual(fake_info_cache['instance_uuid'], obj.instance_uuid)
Beispiel #5
0
 def test_get_by_instance_uuid(self):
     nwinfo = network_model.NetworkInfo.hydrate([{'address': 'foo'}])
     self.mox.StubOutWithMock(db, 'instance_info_cache_get')
     db.instance_info_cache_get(self.context, 'fake-uuid').AndReturn(
         dict(fake_info_cache, network_info=nwinfo.json()))
     self.mox.ReplayAll()
     obj = instance_info_cache.InstanceInfoCache.get_by_instance_uuid(
         self.context, 'fake-uuid')
     self.assertEqual(obj.instance_uuid, 'fake-uuid')
     self.assertEqual(obj.network_info, nwinfo)
     self.assertRemotes()
 def test_get_by_instance_uuid(self):
     nwinfo = network_model.NetworkInfo.hydrate([{'address': 'foo'}])
     self.mox.StubOutWithMock(db, 'instance_info_cache_get')
     db.instance_info_cache_get(self.context, 'fake-uuid').AndReturn(
         dict(fake_info_cache, network_info=nwinfo.json()))
     self.mox.ReplayAll()
     obj = instance_info_cache.InstanceInfoCache.get_by_instance_uuid(
         self.context, 'fake-uuid')
     self.assertEqual(obj.instance_uuid, 'fake-uuid')
     self.assertEqual(obj.network_info, nwinfo)
     self.assertRemotes()
Beispiel #7
0
 def get_by_instance_uuid(cls, context, instance_uuid):
     db_obj = db.instance_info_cache_get(context, instance_uuid)
     if not db_obj:
         raise exception.InstanceInfoCacheNotFound(instance_uuid=instance_uuid)
     return cls._from_db_object(context, cls(context), db_obj)
 def get_by_instance_uuid(cls, context, instance_uuid):
     db_obj = db.instance_info_cache_get(context, instance_uuid)
     if not db_obj:
         raise exception.InstanceInfoCacheNotFound(
                 instance_uuid=instance_uuid)
     return cls._from_db_object(context, cls(context), db_obj)