Hack to support old and new stevedore

See Id675f335957a95fcfce61934dfbfbb2c64af761a, the
_find_entry_points is now list_entry_points.

We should be using extension.ExtensionManager.make_test_instance
to set up the extensions like the one in:
Ie9af444e7f8842ffb3e275ede52b802de02e6e99

Just to get past the problem we have merging stevedore
upper constraints, filing this review

Change-Id: I141b17f9dd2acebe2b23f8fc93206e23bc70b568
This commit is contained in:
Davanum Srinivas 2017-01-28 11:27:05 -05:00
parent 7d0d99571a
commit b55dd079e0
1 changed files with 17 additions and 6 deletions

View File

@ -16,6 +16,7 @@ import os
import mock
import pkg_resources
import stevedore
from glance.common import exception
from glance.common.glare import loader
@ -43,12 +44,22 @@ class TestArtifactsLoader(utils.BaseTestCase):
def _setup_loader(self, artifacts):
self.loader = None
mock_this = 'stevedore.extension.ExtensionManager._find_entry_points'
with mock.patch(mock_this) as fep:
fep.return_value = [
pkg_resources.EntryPoint.parse(art) for art in artifacts]
self.loader = loader.ArtifactsPluginLoader(
'glance.artifacts.types')
try:
# FIXME(dims) : We should not be relying on the internal class
# methods of stevedore.
with mock.patch.object(stevedore.extension.ExtensionManager,
'_find_entry_points') as fep:
fep.return_value = [
pkg_resources.EntryPoint.parse(art) for art in artifacts]
self.loader = loader.ArtifactsPluginLoader(
'glance.artifacts.types')
except AttributeError:
with mock.patch.object(stevedore.extension.ExtensionManager,
'list_entry_points') as fep:
fep.return_value = [
pkg_resources.EntryPoint.parse(art) for art in artifacts]
self.loader = loader.ArtifactsPluginLoader(
'glance.artifacts.types')
def test_load(self):
"""