Commit 4ab6da29 authored by Hanxi Liu's avatar Hanxi Liu

Deprecate olsotest.mockpatch in favor of native fixtures

olso.mockpatch has been deprecated since I3efb3c64ebce396e756a47d110a74fe8604b6b72.
We now remove it in favor of native fixtures.

Change-Id: I28ebf3f672f736c15d8df035179fec80581e937f
parent e462e0dd
......@@ -17,10 +17,10 @@ import functools
import os
import tempfile
import fixtures
import oslo_messaging.conffixture
from oslo_utils import timeutils
from oslotest import base
from oslotest import mockpatch
import six
from testtools import testcase
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(
'ceilometer.messaging.get_transport',
return_value=self.transport))
......
......@@ -21,7 +21,6 @@ import warnings
import fixtures
import mock
from oslotest import mockpatch
import six
from six.moves.urllib import parse as urlparse
import sqlalchemy
......@@ -177,8 +176,8 @@ class TestBase(test_base.BaseTestCase):
self.conn = self.db_manager.connection
self.conn.upgrade()
self.useFixture(mockpatch.Patch('ceilometer.storage.get_connection',
side_effect=self._get_connection))
self.useFixture(fixtures.MockPatch('ceilometer.storage.get_connection',
side_effect=self._get_connection))
# Set a default location for the pipeline config file so the
# tests work even if ceilometer is not installed globally on
......
......@@ -11,9 +11,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
import mock
from oslo_utils import fileutils
from oslotest import mockpatch
import six
from ceilometer.tests.functional.api import v2
......@@ -51,7 +51,7 @@ class TestAPIUpgradePath(v2.FunctionalTest):
self.catalog = (self.ks.session.auth.get_access.
return_value.service_catalog)
self.catalog.url_for.side_effect = self._url_for
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'ceilometer.keystone_client.get_client', return_value=self.ks))
@staticmethod
......
......@@ -19,10 +19,10 @@ import copy
import datetime
import os
import fixtures
import mock
from oslo_utils import fileutils
from oslo_utils import timeutils
from oslotest import mockpatch
import six
from ceilometer.tests.functional.api import v2
......@@ -56,8 +56,8 @@ class TestPostSamples(v2.FunctionalTest):
self.published = []
notifier = mock.Mock()
notifier.sample.side_effect = self.fake_notifier_sample
self.useFixture(mockpatch.Patch('oslo_messaging.Notifier',
return_value=notifier))
self.useFixture(fixtures.MockPatch('oslo_messaging.Notifier',
return_value=notifier))
super(TestPostSamples, self).setUp()
def test_one(self):
......
......@@ -12,13 +12,14 @@
# 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 socket
import fixtures
import mock
import msgpack
import oslo_messaging
from oslo_utils import timeutils
from oslotest import mockpatch
from stevedore import extension
from ceilometer import collector
......@@ -83,7 +84,7 @@ class TestCollector(tests_base.BaseTestCase):
if enabled:
self.setup_messaging(self.CONF)
else:
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'ceilometer.messaging.get_transport',
return_value=None))
......@@ -92,7 +93,7 @@ class TestCollector(tests_base.BaseTestCase):
fake_dispatcher = extension.ExtensionManager.make_test_instance([
extension.Extension('test', None, None, plugin,),
], propagate_map_exceptions=True)
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'ceilometer.dispatcher.load_dispatcher_manager',
return_value=(fake_dispatcher, fake_dispatcher)))
return plugin
......
......@@ -13,12 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
"""Tests for ceilometer agent manager"""
import fixtures
from keystoneauth1 import exceptions as ka_exceptions
import mock
from oslo_utils import fileutils
from oslotest import base
from oslotest import mockpatch
import six
from stevedore import extension
......@@ -259,10 +258,10 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase):
self.notified_samples = []
self.notifier = mock.Mock()
self.notifier.sample.side_effect = self.fake_notifier_sample
self.useFixture(mockpatch.Patch('oslo_messaging.Notifier',
return_value=self.notifier))
self.useFixture(fixtures.MockPatch('oslo_messaging.Notifier',
return_value=self.notifier))
super(TestRunTasks, self).setUp()
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'keystoneclient.v2_0.client.Client',
return_value=mock.Mock()))
......@@ -293,7 +292,7 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase):
def test_when_keystone_fail(self):
"""Test for bug 1316532."""
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'keystoneclient.v2_0.client.Client',
side_effect=ka_exceptions.ClientException))
self.pipeline_cfg = {
......@@ -438,8 +437,8 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase):
self._batching_samples(4, 1)
def _batching_samples(self, expected_samples, call_count):
self.useFixture(mockpatch.PatchObject(manager.utils, 'delayed',
side_effect=fakedelayed))
self.useFixture(fixtures.MockPatchObject(manager.utils, 'delayed',
side_effect=fakedelayed))
pipeline_cfg = {
'sources': [{
'name': 'test_pipeline',
......
......@@ -20,7 +20,6 @@ import fixtures
import mock
from oslo_utils import timeutils
from oslotest import base
from oslotest import mockpatch
import wsme
from ceilometer.api.controllers.v2 import base as v2_base
......@@ -185,9 +184,9 @@ class TestValidateGroupByFields(base.BaseTestCase):
class TestQueryToKwArgs(tests_base.BaseTestCase):
def setUp(self):
super(TestQueryToKwArgs, self).setUp()
self.useFixture(mockpatch.PatchObject(
self.useFixture(fixtures.MockPatchObject(
utils, 'sanitize_query', side_effect=lambda x, y, **z: x))
self.useFixture(mockpatch.PatchObject(
self.useFixture(fixtures.MockPatchObject(
utils, '_verify_query_segregation', side_effect=lambda x, **z: x))
def test_sample_filter_single(self):
......
......@@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
import mock
from oslotest import mockpatch
from ceilometer.compute.virt import inspector as virt_inspector
from ceilometer import service
......@@ -45,7 +45,7 @@ class TestPollsterBase(base.BaseTestCase):
'metering.stack': '2cadc4b4-8789-123c-b4eg-edd2f0a9c128',
'project_cos': 'dev'}
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'ceilometer.compute.virt.inspector.get_hypervisor_inspector',
new=mock.Mock(return_value=self.inspector)))
......@@ -53,7 +53,7 @@ class TestPollsterBase(base.BaseTestCase):
# base compute pollster class, that leads to the fact that we
# need to mock all this class property to avoid context sharing between
# the tests
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'ceilometer.compute.pollsters.'
'GenericComputePollster._get_inspector',
return_value=self.inspector))
......
......@@ -12,9 +12,9 @@
# under the License.
import datetime
import fixtures
import iso8601
import mock
from oslotest import mockpatch
from ceilometer.compute import discovery
from ceilometer.compute.pollsters import util
......@@ -109,15 +109,15 @@ class TestDiscovery(base.BaseTestCase):
# the tests
self.client = mock.MagicMock()
self.client.instance_get_all_by_host.return_value = [self.instance]
patch_client = mockpatch.Patch('ceilometer.nova_client.Client',
return_value=self.client)
patch_client = fixtures.MockPatch('ceilometer.nova_client.Client',
return_value=self.client)
self.useFixture(patch_client)
self.utc_now = mock.MagicMock(
return_value=datetime.datetime(2016, 1, 1,
tzinfo=iso8601.iso8601.UTC))
patch_timeutils = mockpatch.Patch('oslo_utils.timeutils.utcnow',
self.utc_now)
patch_timeutils = fixtures.MockPatch('oslo_utils.timeutils.utcnow',
self.utc_now)
self.useFixture(patch_timeutils)
self.CONF = service.prepare_service([], [])
......
......@@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
from oslo_config import fixture
from oslotest import mockpatch
from ceilometer import dispatcher
from ceilometer import service
......@@ -33,10 +33,10 @@ class TestDispatchManager(base.BaseTestCase):
self.conf.config(meter_dispatchers=['database', 'gnocchi'],
event_dispatchers=['database'])
self.CONF = self.conf.conf
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'ceilometer.dispatcher.gnocchi.GnocchiDispatcher',
new=FakeMeterDispatcher))
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'ceilometer.dispatcher.database.MeterDatabaseDispatcher',
new=FakeMeterDispatcher))
......
......@@ -16,6 +16,7 @@
import os
import uuid
import fixtures
from gnocchiclient import exceptions as gnocchi_exc
from keystoneauth1 import exceptions as ka_exceptions
import mock
......@@ -23,7 +24,6 @@ from oslo_config import fixture as config_fixture
from oslo_utils import fileutils
from oslo_utils import fixture as utils_fixture
from oslo_utils import timeutils
from oslotest import mockpatch
import requests
import six
from stevedore import extension
......@@ -360,7 +360,7 @@ class DispatcherTest(base.BaseTestCase):
ks_client = mock.Mock(auth_token='fake_token')
ks_client.projects.find.return_value = mock.Mock(
name='gnocchi', id='a2d42c23-d518-46b6-96ab-3fba2e146859')
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'ceilometer.keystone_client.get_client',
return_value=ks_client))
self.ks_client = ks_client
......@@ -613,7 +613,7 @@ class DispatcherWorkflowTest(base.BaseTestCase,
ks_client = mock.Mock()
ks_client.projects.find.return_value = mock.Mock(
name='gnocchi', id='a2d42c23-d518-46b6-96ab-3fba2e146859')
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'ceilometer.keystone_client.get_client',
return_value=ks_client))
self.ks_client = ks_client
......
......@@ -14,10 +14,10 @@
# under the License.
"""Tests for Ceilometer notify daemon."""
import fixtures
import mock
import oslo_messaging
from oslo_utils import fileutils
from oslotest import mockpatch
import six
import yaml
......@@ -127,10 +127,11 @@ class TestEventEndpoint(tests_base.BaseTestCase):
self.CONF.set_override("connection", "log://", group='database')
self.setup_messaging(self.CONF)
self.useFixture(mockpatch.PatchObject(publisher, 'get_publisher',
side_effect=self.get_publisher))
self.useFixture(fixtures.MockPatchObject(
publisher, 'get_publisher',
side_effect=self.get_publisher))
self.fake_publisher = mock.Mock()
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'ceilometer.publisher.test.TestPublisher',
return_value=self.fake_publisher))
......
......@@ -14,9 +14,9 @@
# under the License.
"""Tests for ceilometer/hardware/inspector/snmp/inspector.py
"""
import fixtures
import mock
from oslo_utils import netutils
from oslotest import mockpatch
from pysnmp.proto.rfc1905 import noSuchObject
from ceilometer.hardware.inspector import snmp
......@@ -84,7 +84,7 @@ class TestSNMPInspector(test_base.BaseTestCase):
super(TestSNMPInspector, self).setUp()
self.inspector = snmp.SNMPInspector()
self.host = netutils.urlsplit("snmp://localhost")
self.useFixture(mockpatch.PatchObject(
self.useFixture(fixtures.MockPatchObject(
snmp.cmdgen, 'CommandGenerator',
return_value=FakeCommandGenerator()))
......@@ -95,7 +95,7 @@ class TestSNMPInspector(test_base.BaseTestCase):
def faux_parse(ret, is_bulk):
return (True, 'forced error')
self.useFixture(mockpatch.PatchObject(
self.useFixture(fixtures.MockPatchObject(
snmp, 'parse_snmp_return', new=faux_parse))
self.assertRaises(snmp.SNMPException,
......
......@@ -17,8 +17,8 @@ import mock
import six
import yaml
import fixtures
from oslo_utils import fileutils
from oslotest import mockpatch
from ceilometer import declarative
from ceilometer.hardware.inspector import base as inspector_base
......@@ -111,7 +111,7 @@ class TestGenericPollsters(test_base.BaseTestCase):
super(TestGenericPollsters, self).setUp()
self.conf = service.prepare_service([], [])
self.resources = ["snmp://test", "snmp://test2"]
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'ceilometer.hardware.inspector.get_inspector',
self.faux_get_inspector))
self.pollster = generic.GenericHardwareDeclarativePollster(self.conf)
......
......@@ -14,8 +14,8 @@
import abc
import fixtures
import mock
from oslotest import mockpatch
import six
from ceilometer.agent import manager
......@@ -53,11 +53,11 @@ class TestPollsterBase(base.BaseTestCase):
nm.read_sensor_any.side_effect = self.fake_sensor_data
# We should mock the pollster first before initialize the Manager
# so that we don't trigger the sudo in pollsters' __init__().
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'ceilometer.ipmi.platform.intel_node_manager.NodeManager',
return_value=nm))
self.useFixture(mockpatch.Patch(
self.useFixture(fixtures.MockPatch(
'ceilometer.ipmi.platform.ipmi_sensor.IPMISensor',
return_value=nm))
......
......@@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
import mock
from oslotest import base
from oslotest import mockpatch
from ceilometer.agent import manager
from ceilometer.agent import plugin_base
......@@ -45,9 +45,9 @@ class TestFirewallPollster(_BaseTestFWPollster):
super(TestFirewallPollster, self).setUp()
self.pollster = fwaas.FirewallPollster(self.CONF)
fake_fw = self.fake_get_fw_service()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'firewall_get_all',
return_value=fake_fw))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'firewall_get_all',
return_value=fake_fw))
@staticmethod
def fake_get_fw_service():
......@@ -123,9 +123,9 @@ class TestIPSecConnectionsPollster(_BaseTestFWPollster):
super(TestIPSecConnectionsPollster, self).setUp()
self.pollster = fwaas.FirewallPolicyPollster(self.CONF)
fake_fw_policy = self.fake_get_fw_policy()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'fw_policy_get_all',
return_value=fake_fw_policy))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'fw_policy_get_all',
return_value=fake_fw_policy))
@staticmethod
def fake_get_fw_policy():
......
......@@ -13,10 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
import mock
from oslotest import base
from oslotest import mockpatch
from ceilometer.agent import manager
from ceilometer.agent import plugin_base
......@@ -49,9 +48,9 @@ class TestLBPoolPollster(_BaseTestLBPollster):
super(TestLBPoolPollster, self).setUp()
self.pollster = lbaas.LBPoolPollster(self.CONF)
fake_pools = self.fake_get_pools()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'pool_get_all',
return_value=fake_pools))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'pool_get_all',
return_value=fake_pools))
@staticmethod
def fake_get_pools():
......@@ -173,9 +172,9 @@ class TestLBVipPollster(_BaseTestLBPollster):
super(TestLBVipPollster, self).setUp()
self.pollster = lbaas.LBVipPollster(self.CONF)
fake_vips = self.fake_get_vips()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'vip_get_all',
return_value=fake_vips))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'vip_get_all',
return_value=fake_vips))
@staticmethod
def fake_get_vips():
......@@ -297,9 +296,9 @@ class TestLBMemberPollster(_BaseTestLBPollster):
super(TestLBMemberPollster, self).setUp()
self.pollster = lbaas.LBMemberPollster(self.CONF)
fake_members = self.fake_get_members()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'member_get_all',
return_value=fake_members))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'member_get_all',
return_value=fake_members))
@staticmethod
def fake_get_members():
......@@ -391,9 +390,9 @@ class TestLBHealthProbePollster(_BaseTestLBPollster):
super(TestLBHealthProbePollster, self).setUp()
self.pollster = lbaas.LBHealthMonitorPollster(self.CONF)
fake_health_monitor = self.fake_get_health_monitor()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'health_monitor_get_all',
return_value=fake_health_monitor))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'health_monitor_get_all',
return_value=fake_health_monitor))
@staticmethod
def fake_get_health_monitor():
......@@ -434,14 +433,14 @@ class TestLBStatsPollster(_BaseTestLBPollster):
def setUp(self):
super(TestLBStatsPollster, self).setUp()
fake_pool_stats = self.fake_pool_stats()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'pool_stats',
return_value=fake_pool_stats))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'pool_stats',
return_value=fake_pool_stats))
fake_pools = self.fake_get_pools()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'pool_get_all',
return_value=fake_pools))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'pool_get_all',
return_value=fake_pools))
@staticmethod
def fake_get_pools():
......
......@@ -12,10 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
import mock
from oslotest import base
from oslotest import mockpatch
from ceilometer.agent import manager
from ceilometer.agent import plugin_base
......@@ -46,9 +45,9 @@ class TestLBListenerPollster(_BaseTestLBPollster):
self.pollster = lbaas.LBListenerPollster(self.CONF)
self.pollster.lb_version = 'v2'
fake_listeners = self.fake_list_listeners()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'list_listener',
return_value=fake_listeners))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'list_listener',
return_value=fake_listeners))
@staticmethod
def fake_list_listeners():
......@@ -144,9 +143,9 @@ class TestLBLoadBalancerPollster(_BaseTestLBPollster):
self.pollster = lbaas.LBLoadBalancerPollster(self.CONF)
self.pollster.lb_version = 'v2'
fake_loadbalancers = self.fake_list_loadbalancers()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'list_loadbalancer',
return_value=fake_loadbalancers))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'list_loadbalancer',
return_value=fake_loadbalancers))
@staticmethod
def fake_list_loadbalancers():
......@@ -232,14 +231,14 @@ class TestLBStatsPollster(_BaseTestLBPollster):
def setUp(self):
super(TestLBStatsPollster, self).setUp()
fake_balancer_stats = self.fake_balancer_stats()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'get_loadbalancer_stats',
return_value=fake_balancer_stats))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'get_loadbalancer_stats',
return_value=fake_balancer_stats))
fake_loadbalancers = self.fake_list_loadbalancers()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'list_loadbalancer',
return_value=fake_loadbalancers))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'list_loadbalancer',
return_value=fake_loadbalancers))
self.CONF.set_override('neutron_lbaas_version',
'v2',
group='service_types')
......
......@@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
import mock
from oslotest import base
from oslotest import mockpatch
from ceilometer.agent import manager
from ceilometer.agent import plugin_base
......@@ -45,9 +45,9 @@ class TestVPNServicesPollster(_BaseTestVPNPollster):
super(TestVPNServicesPollster, self).setUp()
self.pollster = vpnaas.VPNServicesPollster(self.CONF)
fake_vpn = self.fake_get_vpn_service()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'vpn_get_all',
return_value=fake_vpn))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'vpn_get_all',
return_value=fake_vpn))
@staticmethod
def fake_get_vpn_service():
......@@ -127,9 +127,9 @@ class TestIPSecConnectionsPollster(_BaseTestVPNPollster):
super(TestIPSecConnectionsPollster, self).setUp()
self.pollster = vpnaas.IPSecConnectionsPollster(self.CONF)
fake_conns = self.fake_get_ipsec_connections()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'ipsec_site_connections_get_all',
return_value=fake_conns))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'ipsec_site_connections_get_all',
return_value=fake_conns))
@staticmethod
def fake_get_ipsec_connections():
......
......@@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
import mock
from oslotest import base
from oslotest import mockpatch
from ceilometer.agent import manager
from ceilometer.agent import plugin_base
......@@ -41,9 +41,9 @@ class TestFloatingIPPollster(_BaseTestFloatingIPPollster):
super(TestFloatingIPPollster, self).setUp()
self.pollster = floatingip.FloatingIPPollster(self.CONF)
fake_fip = self.fake_get_fip_service()
self.useFixture(mockpatch.Patch('ceilometer.neutron_client.Client.'
'fip_get_all',
return_value=fake_fip))
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'fip_get_all',
return_value=fake_fip))
@staticmethod
def fake_get_fip_service():
......
......@@ -14,10 +14,10 @@
import collections
import fixtures
from keystoneauth1 import exceptions
import mock
from oslotest import base
from oslotest import mockpatch
import testscenarios.testcase
from ceilometer.agent import manager
......@@ -105,8 +105,8 @@ class TestRgwPollster(testscenarios.testcase.WithScenarios,
def test_iter_accounts_no_cache(self):
cache = {}
with mockpatch.PatchObject(self.factory, '_get_account_info',
return_value=[]):
with fixtures.MockPatchObject(self.factory, '_get_account_info',
return_value=[]):
data = list(self.pollster._iter_accounts(mock.Mock(), cache,
ASSIGNED_TENANTS))
......@@ -123,24 +123,24 @@ class TestRgwPollster(testscenarios.testcase.WithScenarios,
api_method = 'get_%s' % self.pollster.METHOD
with mockpatch.PatchObject(rgw_client.RGWAdminClient,
api_method, new=mock_method):
with fixtures.MockPatchObject(rgw_client.RGWAdminClient,
api_method, new=mock_method):
cache = {self.pollster.CACHE_KEY_METHOD: [self.ACCOUNTS[0]]}
data = list(self.pollster._iter_accounts(mock.Mock(), cache,
ASSIGNED_TENANTS))
self.assertEqual([self.ACCOUNTS[0]], data)
def test_metering(self):
with mockpatch.PatchObject(self.factory, '_iter_accounts',
side_effect=self.fake_iter_accounts):
with fixtures.MockPatchObject(self.factory, '_iter_accounts',
side_effect=self.fake_iter_accounts):
samples = list(self.pollster.get_samples(self.manager, {},
ASSIGNED_TENANTS))
self.assertEqual(2, len(samples), self.pollster.__class__)
def test_get_meter_names(self):
with mockpatch.PatchObject(self.factory, '_iter_accounts',
side_effect=self.fake_iter_accounts):
with fixtures.MockPatchObject(self.factory, '_iter_accounts',
side_effect=self.fake_iter_accounts):
samples = list(self.pollster.get_samples(self.manager, {},
ASSIGNED_TENANTS))
......@@ -151,9 +151,9 @@ class TestRgwPollster(testscenarios.testcase.WithScenarios,
mock_method = mock.MagicMock()
endpoint = 'http://127.0.0.1:8000/admin'
api_method = 'get_%s' % self.pollster.METHOD
with mockpatch.PatchObject(rgw_client.RGWAdminClient,
api_method, new=mock_method):
with mockpatch.PatchObject(
with fixtures.MockPatchObject(rgw_client.RGWAdminClient,
api_method, new=mock_method):
with fixtures.Mock