def test_get_volume_mapping_by_uuid(self, mock_write, mock_read): mock_read.side_effect = etcd.EtcdKeyNotFound volume_mapping = utils.create_test_volume_mapping(context=self.context) mock_read.side_effect = lambda *args: FakeEtcdResult(volume_mapping. as_dict()) res = dbapi.get_volume_mapping_by_uuid(self.context, volume_mapping.uuid) self.assertEqual(volume_mapping.id, res.id) self.assertEqual(volume_mapping.uuid, res.uuid)
def get_by_uuid(cls, context, uuid): """Find a volume mapping based on uuid. :param uuid: the uuid of a volume mapping. :param context: Security context :returns: a :class:`VolumeMapping` object. """ db_volume = dbapi.get_volume_mapping_by_uuid(context, uuid) volume = VolumeMapping._from_db_object(cls(context), db_volume) return volume
def test_get_volume_mapping_by_uuid(self): volume_mapping = utils.create_test_volume_mapping(context=self.context) res = dbapi.get_volume_mapping_by_uuid(self.context, volume_mapping.uuid) self.assertEqual(volume_mapping.id, res.id) self.assertEqual(volume_mapping.uuid, res.uuid)