Merge "Use mockpatch fixtures from fixtures"
This commit is contained in:
@@ -14,11 +14,11 @@
|
||||
|
||||
import uuid
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as config_fixture
|
||||
from oslo_utils import importutils
|
||||
from oslotest import mockpatch
|
||||
import stevedore
|
||||
from stevedore import extension
|
||||
|
||||
@@ -45,7 +45,7 @@ class TestLoadAuthMethod(unit.BaseTestCase):
|
||||
fake_driver_manager = stevedore.DriverManager.make_test_instance(
|
||||
extension_, namespace=auth_plugin_namespace)
|
||||
|
||||
driver_manager_mock = self.useFixture(mockpatch.PatchObject(
|
||||
driver_manager_mock = self.useFixture(fixtures.MockPatchObject(
|
||||
stevedore, 'DriverManager', return_value=fake_driver_manager)).mock
|
||||
|
||||
driver = controllers.load_auth_method(method)
|
||||
@@ -66,10 +66,10 @@ class TestLoadAuthMethod(unit.BaseTestCase):
|
||||
|
||||
# stevedore.DriverManager raises RuntimeError if it can't load the
|
||||
# driver.
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
self.useFixture(fixtures.MockPatchObject(
|
||||
stevedore, 'DriverManager', side_effect=RuntimeError))
|
||||
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
self.useFixture(fixtures.MockPatchObject(
|
||||
importutils, 'import_object', return_value=mock.sentinel.driver))
|
||||
|
||||
driver = controllers.load_auth_method(method)
|
||||
@@ -86,13 +86,13 @@ class TestLoadAuthMethod(unit.BaseTestCase):
|
||||
|
||||
# stevedore.DriverManager raises RuntimeError if it can't load the
|
||||
# driver.
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
self.useFixture(fixtures.MockPatchObject(
|
||||
stevedore, 'DriverManager', side_effect=RuntimeError))
|
||||
|
||||
class TestException(Exception):
|
||||
pass
|
||||
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
self.useFixture(fixtures.MockPatchObject(
|
||||
importutils, 'import_object', side_effect=TestException))
|
||||
|
||||
self.assertRaises(TestException, controllers.load_auth_method, method)
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
import logging
|
||||
import uuid
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as config_fixture
|
||||
from oslotest import mockpatch
|
||||
from pycadf import cadftaxonomy
|
||||
from pycadf import cadftype
|
||||
from pycadf import eventfactory
|
||||
@@ -225,7 +225,7 @@ class BaseNotificationTest(test_v3.RestfulTestCase):
|
||||
note['actor_operation'] = actor_dict.get('actor_operation')
|
||||
self._notifications.append(note)
|
||||
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
self.useFixture(fixtures.MockPatchObject(
|
||||
notifications, '_send_notification', fake_notify))
|
||||
|
||||
def fake_audit(action, initiator, outcome, target,
|
||||
@@ -249,7 +249,7 @@ class BaseNotificationTest(test_v3.RestfulTestCase):
|
||||
'send_notification_called': True}
|
||||
self._audits.append(audit)
|
||||
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
self.useFixture(fixtures.MockPatchObject(
|
||||
notifications, '_send_audit_notification', fake_audit))
|
||||
|
||||
def _assert_last_note(self, resource_id, operation, resource_type,
|
||||
@@ -993,7 +993,7 @@ class CadfNotificationsWrapperTestCase(test_v3.RestfulTestCase):
|
||||
'send_notification_called': True}
|
||||
self._notifications.append(note)
|
||||
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
self.useFixture(fixtures.MockPatchObject(
|
||||
notifications, '_send_audit_notification', fake_notify))
|
||||
|
||||
def _assert_last_note(self, action, user_id, event_type=None):
|
||||
|
||||
@@ -36,7 +36,6 @@ from oslo_context import fixture as oslo_ctx_fixture
|
||||
from oslo_log import fixture as log_fixture
|
||||
from oslo_log import log
|
||||
from oslo_utils import timeutils
|
||||
from oslotest import mockpatch
|
||||
from paste.deploy import loadwsgi
|
||||
import six
|
||||
from sqlalchemy import exc
|
||||
@@ -517,8 +516,8 @@ class BaseTestCase(testtools.TestCase):
|
||||
self.useFixture(fixtures.NestedTempfile())
|
||||
self.useFixture(fixtures.TempHomeDir())
|
||||
|
||||
self.useFixture(mockpatch.PatchObject(sys, 'exit',
|
||||
side_effect=UnexpectedExit))
|
||||
self.useFixture(fixtures.MockPatchObject(sys, 'exit',
|
||||
side_effect=UnexpectedExit))
|
||||
self.useFixture(log_fixture.get_logging_handle_error_fixture())
|
||||
|
||||
warnings.filterwarnings('error', category=DeprecationWarning,
|
||||
@@ -634,7 +633,7 @@ class TestCase(BaseTestCase):
|
||||
# cleanup.
|
||||
def mocked_register_auth_plugin_opt(conf, opt):
|
||||
self.config_fixture.register_opt(opt, group='auth')
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
self.useFixture(fixtures.MockPatchObject(
|
||||
config, '_register_auth_plugin_opt',
|
||||
new=mocked_register_auth_plugin_opt))
|
||||
|
||||
|
||||
@@ -13,11 +13,10 @@
|
||||
import copy
|
||||
import uuid
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
from testtools import matchers
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslotest import mockpatch
|
||||
from testtools import matchers
|
||||
|
||||
from keystone import exception
|
||||
from keystone.tests import unit
|
||||
@@ -87,7 +86,7 @@ class TestResourceManagerNoFixtures(unit.SQLDriverOverrides, unit.TestCase):
|
||||
def test_ensure_default_domain_exists_fails(self):
|
||||
# When there's an unexpected exception creating domain it's passed on.
|
||||
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
self.useFixture(fixtures.MockPatchObject(
|
||||
self.resource_api, 'create_domain',
|
||||
side_effect=exception.UnexpectedError))
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
import copy
|
||||
import uuid
|
||||
|
||||
import fixtures
|
||||
import ldap
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_log import versionutils
|
||||
from oslotest import mockpatch
|
||||
import pkg_resources
|
||||
from six.moves import http_client
|
||||
from six.moves import range
|
||||
@@ -2152,7 +2152,8 @@ class LDAPIdentityEnabledEmulation(LDAPIdentity):
|
||||
sample_dn_filter_esc)
|
||||
|
||||
with mixin_impl.get_connection() as conn:
|
||||
m = self.useFixture(mockpatch.PatchObject(conn, 'search_s')).mock
|
||||
m = self.useFixture(
|
||||
fixtures.MockPatchObject(conn, 'search_s')).mock
|
||||
mixin_impl._get_enabled(object_id, conn)
|
||||
# The 3rd argument is the DN.
|
||||
self.assertEqual(exp_filter, m.call_args[0][2])
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import fixtures
|
||||
import ldappool
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslotest import mockpatch
|
||||
|
||||
from keystone.common.ldap import core as ldap_core
|
||||
from keystone.identity.backends import ldap
|
||||
@@ -213,7 +213,7 @@ class LDAPIdentity(LdapPoolCommonTestMixin,
|
||||
"""Executes tests in existing base class with pooled LDAP handler."""
|
||||
|
||||
def setUp(self):
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
self.useFixture(fixtures.MockPatchObject(
|
||||
ldap_core.PooledLDAPHandler, 'Connector', fakeldap.FakeLdapPool))
|
||||
super(LDAPIdentity, self).setUp()
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ from oslo_config import cfg
|
||||
from oslo_log import versionutils
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import importutils
|
||||
from oslotest import mockpatch
|
||||
import saml2
|
||||
from saml2 import saml
|
||||
from saml2 import sigver
|
||||
@@ -1588,7 +1587,7 @@ class FederatedTokenTests(test_v3.RestfulTestCase, FederatedSetupMixin):
|
||||
'send_notification_called': True}
|
||||
self._notifications.append(note)
|
||||
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
self.useFixture(fixtures.MockPatchObject(
|
||||
notifications,
|
||||
'send_saml_audit_notification',
|
||||
fake_saml_notify))
|
||||
|
||||
Reference in New Issue
Block a user