Merge "Remove moxstubout usage"
This commit is contained in:
commit
aee8a72490
|
@ -161,19 +161,6 @@ def stub_out_registry_and_store_server(stubs, base_dir, **kwargs):
|
||||||
setattr(res, 'read', fake_reader)
|
setattr(res, 'read', fake_reader)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def fake_get_connection_type(client):
|
|
||||||
"""Returns the proper connection type."""
|
|
||||||
DEFAULT_REGISTRY_PORT = 9191
|
|
||||||
DEFAULT_API_PORT = 9292
|
|
||||||
|
|
||||||
if (client.port == DEFAULT_API_PORT and
|
|
||||||
client.host == '0.0.0.0'):
|
|
||||||
return FakeGlanceConnection
|
|
||||||
elif (client.port == DEFAULT_REGISTRY_PORT and
|
|
||||||
client.host == '0.0.0.0'):
|
|
||||||
rserver = kwargs.get("registry")
|
|
||||||
return FakeRegistryConnection(registry=rserver)
|
|
||||||
|
|
||||||
def fake_image_iter(self):
|
def fake_image_iter(self):
|
||||||
for i in self.source.app_iter:
|
for i in self.source.app_iter:
|
||||||
yield i
|
yield i
|
||||||
|
@ -187,9 +174,5 @@ def stub_out_registry_and_store_server(stubs, base_dir, **kwargs):
|
||||||
assert glance.common.client.SENDFILE_SUPPORTED
|
assert glance.common.client.SENDFILE_SUPPORTED
|
||||||
return force
|
return force
|
||||||
|
|
||||||
stubs.Set(glance.common.client.BaseClient, 'get_connection_type',
|
|
||||||
fake_get_connection_type)
|
|
||||||
setattr(glance.common.client.BaseClient, '_stub_orig_sendable',
|
setattr(glance.common.client.BaseClient, '_stub_orig_sendable',
|
||||||
glance.common.client.BaseClient._sendable)
|
glance.common.client.BaseClient._sendable)
|
||||||
stubs.Set(glance.common.client.BaseClient, '_sendable',
|
|
||||||
fake_sendable)
|
|
||||||
|
|
|
@ -103,9 +103,23 @@ class IsolatedUnitTest(StoreClearingUnitTest):
|
||||||
group="glance_store")
|
group="glance_store")
|
||||||
|
|
||||||
store.create_stores()
|
store.create_stores()
|
||||||
stubs.stub_out_registry_and_store_server(self.stubs,
|
|
||||||
self.test_dir,
|
def fake_get_conection_type(client):
|
||||||
registry=self.registry)
|
DEFAULT_REGISTRY_PORT = 9191
|
||||||
|
DEFAULT_API_PORT = 9292
|
||||||
|
|
||||||
|
if (client.port == DEFAULT_API_PORT and
|
||||||
|
client.host == '0.0.0.0'):
|
||||||
|
return stubs.FakeGlanceConnection
|
||||||
|
elif (client.port == DEFAULT_REGISTRY_PORT and
|
||||||
|
client.host == '0.0.0.0'):
|
||||||
|
return stubs.FakeRegistryConnection(registry=self.registry)
|
||||||
|
|
||||||
|
self.patcher = mock.patch(
|
||||||
|
'glance.common.client.BaseClient.get_connection_type',
|
||||||
|
fake_get_conection_type)
|
||||||
|
self.addCleanup(self.patcher.stop)
|
||||||
|
self.patcher.start()
|
||||||
|
|
||||||
def set_policy_rules(self, rules):
|
def set_policy_rules(self, rules):
|
||||||
fap = open(CONF.oslo_policy.policy_file, 'w')
|
fap = open(CONF.oslo_policy.policy_file, 'w')
|
||||||
|
@ -127,7 +141,7 @@ class MultiIsolatedUnitTest(MultiStoreClearingUnitTest):
|
||||||
lockutils.set_defaults(os.path.join(self.test_dir))
|
lockutils.set_defaults(os.path.join(self.test_dir))
|
||||||
|
|
||||||
self.config(debug=False)
|
self.config(debug=False)
|
||||||
stubs.stub_out_registry_and_store_server(self.stubs,
|
stubs.stub_out_registry_and_store_server(self,
|
||||||
self.test_dir,
|
self.test_dir,
|
||||||
registry=self.registry)
|
registry=self.registry)
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ from oslo_config import fixture as cfg_fixture
|
||||||
from oslo_log.fixture import logging_error as log_fixture
|
from oslo_log.fixture import logging_error as log_fixture
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslotest import moxstubout
|
|
||||||
import six
|
import six
|
||||||
from six.moves import BaseHTTPServer
|
from six.moves import BaseHTTPServer
|
||||||
from six.moves import http_client as http
|
from six.moves import http_client as http
|
||||||
|
@ -78,8 +77,6 @@ class BaseTestCase(testtools.TestCase):
|
||||||
# the following policy tests
|
# the following policy tests
|
||||||
config.parse_args(args=[])
|
config.parse_args(args=[])
|
||||||
self.addCleanup(CONF.reset)
|
self.addCleanup(CONF.reset)
|
||||||
mox_fixture = self.useFixture(moxstubout.MoxStubout())
|
|
||||||
self.stubs = mox_fixture.stubs
|
|
||||||
self.mock_object(exception, '_FATAL_EXCEPTION_FORMAT_ERRORS', True)
|
self.mock_object(exception, '_FATAL_EXCEPTION_FORMAT_ERRORS', True)
|
||||||
self.test_dir = self.useFixture(fixtures.TempDir()).path
|
self.test_dir = self.useFixture(fixtures.TempDir()).path
|
||||||
self.conf_dir = os.path.join(self.test_dir, 'etc')
|
self.conf_dir = os.path.join(self.test_dir, 'etc')
|
||||||
|
|
Loading…
Reference in New Issue