Useing fixtures.MockPatch instead of mockpatch.Patch
This module has been deprecated in favor of fixtures.MockPatch. Change-Id: I52b6b8b49b32f8203c93ce044898a4c6ab5794ea
This commit is contained in:
parent
55e63d4e2a
commit
4fb5f46d04
@ -15,6 +15,7 @@
|
||||
# under the License.
|
||||
"""Test base classes.
|
||||
"""
|
||||
import fixtures
|
||||
import functools
|
||||
import os.path
|
||||
import unittest
|
||||
@ -22,7 +23,6 @@ import unittest
|
||||
import oslo_messaging.conffixture
|
||||
from oslo_utils import timeutils
|
||||
from oslotest import base
|
||||
from oslotest import mockpatch
|
||||
import six
|
||||
import webtest
|
||||
|
||||
@ -41,7 +41,7 @@ class BaseTestCase(base.BaseTestCase):
|
||||
# NOTE(sileht): Ensure a new oslo.messaging driver is loaded
|
||||
# between each tests
|
||||
self.transport = messaging.get_transport(conf, "fake://", cache=False)
|
||||
self.useFixture(mockpatch.Patch(
|
||||
self.useFixture(fixtures.MockPatch(
|
||||
'aodh.messaging.get_transport',
|
||||
return_value=self.transport))
|
||||
|
||||
|
@ -21,7 +21,6 @@ import os
|
||||
import fixtures
|
||||
from oslo_config import fixture as fixture_config
|
||||
from oslo_utils import uuidutils
|
||||
from oslotest import mockpatch
|
||||
import six
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
@ -110,7 +109,7 @@ class TestBase(test_base.BaseTestCase):
|
||||
self.alarm_conn = storage.get_connection_from_config(self.CONF)
|
||||
self.alarm_conn.upgrade()
|
||||
|
||||
self.useFixture(mockpatch.Patch(
|
||||
self.useFixture(fixtures.MockPatch(
|
||||
'aodh.storage.get_connection_from_config',
|
||||
side_effect=self._get_connection))
|
||||
|
||||
|
@ -13,10 +13,10 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import fixtures
|
||||
import mock
|
||||
from oslo_config import fixture
|
||||
from oslotest import base
|
||||
from oslotest import mockpatch
|
||||
|
||||
from aodh import service
|
||||
|
||||
@ -27,8 +27,9 @@ class TestEvaluatorBase(base.BaseTestCase):
|
||||
conf = service.prepare_service(argv=[], config_files=[])
|
||||
self.conf = self.useFixture(fixture.Config(conf)).conf
|
||||
self.api_client = mock.Mock()
|
||||
self.useFixture(mockpatch.Patch('ceilometerclient.client.get_client',
|
||||
return_value=self.api_client))
|
||||
self.useFixture(
|
||||
fixtures.MockPatch('ceilometerclient.client.get_client',
|
||||
return_value=self.api_client))
|
||||
self.evaluator = self.EVALUATOR(self.conf)
|
||||
self.notifier = mock.MagicMock()
|
||||
self.evaluator.notifier = self.notifier
|
||||
|
@ -14,10 +14,10 @@
|
||||
"""
|
||||
|
||||
from ceilometerclient.v2 import statistics
|
||||
import fixtures
|
||||
import mock
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from oslotest import mockpatch
|
||||
import six
|
||||
from six import moves
|
||||
|
||||
@ -32,7 +32,7 @@ class BaseCompositeEvaluate(base.TestEvaluatorBase):
|
||||
EVALUATOR = composite.CompositeEvaluator
|
||||
|
||||
def setUp(self):
|
||||
self.client = self.useFixture(mockpatch.Patch(
|
||||
self.client = self.useFixture(fixtures.MockPatch(
|
||||
'aodh.evaluator.gnocchi.client'
|
||||
)).mock.Client.return_value
|
||||
super(BaseCompositeEvaluate, self).setUp()
|
||||
|
@ -14,13 +14,13 @@
|
||||
# under the License.
|
||||
|
||||
import datetime
|
||||
import fixtures
|
||||
import unittest
|
||||
|
||||
from gnocchiclient import exceptions
|
||||
import mock
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from oslotest import mockpatch
|
||||
import pytz
|
||||
import six
|
||||
from six import moves
|
||||
@ -33,7 +33,7 @@ from aodh.tests.unit.evaluator import base
|
||||
|
||||
class TestGnocchiEvaluatorBase(base.TestEvaluatorBase):
|
||||
def setUp(self):
|
||||
self.client = self.useFixture(mockpatch.Patch(
|
||||
self.client = self.useFixture(fixtures.MockPatch(
|
||||
'aodh.evaluator.gnocchi.client'
|
||||
)).mock.Client.return_value
|
||||
self.prepared_alarms = [
|
||||
|
@ -14,11 +14,11 @@
|
||||
# under the License.
|
||||
"""Tests for aodh.evaluator.AlarmEvaluationService.
|
||||
"""
|
||||
import fixtures
|
||||
import time
|
||||
|
||||
import mock
|
||||
from oslo_config import fixture as fixture_config
|
||||
from oslotest import mockpatch
|
||||
from stevedore import extension
|
||||
|
||||
from aodh import evaluator
|
||||
@ -47,15 +47,15 @@ class TestAlarmEvaluationService(tests_base.BaseTestCase):
|
||||
]
|
||||
)
|
||||
|
||||
self.useFixture(mockpatch.Patch(
|
||||
self.useFixture(fixtures.MockPatch(
|
||||
'stevedore.extension.ExtensionManager',
|
||||
return_value=self._fake_em
|
||||
))
|
||||
self.useFixture(mockpatch.Patch(
|
||||
self.useFixture(fixtures.MockPatch(
|
||||
'aodh.coordination.PartitionCoordinator',
|
||||
return_value=self._fake_pc
|
||||
))
|
||||
self.useFixture(mockpatch.Patch(
|
||||
self.useFixture(fixtures.MockPatch(
|
||||
'aodh.storage.get_connection_from_config',
|
||||
return_value=self._fake_conn
|
||||
))
|
||||
|
@ -12,13 +12,13 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import fixtures
|
||||
import time
|
||||
|
||||
import mock
|
||||
from oslo_config import fixture as fixture_config
|
||||
import oslo_messaging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslotest import mockpatch
|
||||
import requests
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
@ -65,7 +65,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
||||
self.transport, topics=['alarming'], driver='messaging',
|
||||
publisher_id='testpublisher')
|
||||
self.zaqar = FakeZaqarClient(self)
|
||||
self.useFixture(mockpatch.Patch(
|
||||
self.useFixture(fixtures.MockPatch(
|
||||
'aodh.notifier.zaqar.ZaqarAlarmNotifier.get_zaqar_client',
|
||||
return_value=self.zaqar))
|
||||
self.service = notifier.AlarmNotifierService(0, self.CONF)
|
||||
@ -356,8 +356,8 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
||||
client.session.auth.get_access.return_value.auth_token = 'token_1234'
|
||||
|
||||
self.useFixture(
|
||||
mockpatch.Patch('aodh.keystone_client.get_trusted_client',
|
||||
lambda *args: client))
|
||||
fixtures.MockPatch('aodh.keystone_client.get_trusted_client',
|
||||
lambda *args: client))
|
||||
|
||||
with mock.patch.object(requests.Session, 'post') as poster:
|
||||
self._msg_notifier.sample({}, 'alarm.update',
|
||||
@ -410,8 +410,8 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
||||
client.session.auth.get_access.return_value.auth_token = 'token_1234'
|
||||
|
||||
self.useFixture(
|
||||
mockpatch.Patch('aodh.keystone_client.get_trusted_client',
|
||||
lambda *args: client))
|
||||
fixtures.MockPatch('aodh.keystone_client.get_trusted_client',
|
||||
lambda *args: client))
|
||||
|
||||
action = 'trust+zaqar://trust-1234:delete@?queue_name=foobar-critical'
|
||||
self._msg_notifier.sample({}, 'alarm.update',
|
||||
|
Loading…
x
Reference in New Issue
Block a user