Move ceilometerclient mock to evaluator/base

Move the mocking of ceilometerclient into base.py under
evaluator in order to fix test run.

Closes-Bug: #1483577
Change-Id: Ieb877f96da0a5ae4d29e357c8b53ad8c5af9c713
This commit is contained in:
Ildiko Vancsa 2015-08-11 10:17:16 +02:00
parent d12b4e782f
commit db96abb5a6
3 changed files with 3 additions and 6 deletions

View File

@ -16,6 +16,7 @@
import mock
from oslo_config import fixture
from oslotest import base
from oslotest import mockpatch
from aodh import service
@ -26,6 +27,8 @@ class TestEvaluatorBase(base.BaseTestCase):
conf = service.prepare_service([])
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.notifier = mock.MagicMock()
self.evaluator = self.EVALUATOR(self.conf, self.notifier)
self.storage_conn = mock.MagicMock()

View File

@ -47,8 +47,6 @@ class TestGnocchiThresholdEvaluate(base.TestEvaluatorBase):
def setUp(self):
super(TestGnocchiThresholdEvaluate, self).setUp()
self.useFixture(mockpatch.Patch('ceilometerclient.client.get_client',
return_value=self.api_client))
self.requests = self.useFixture(mockpatch.Patch(
'aodh.evaluator.gnocchi.requests')).mock

View File

@ -113,10 +113,6 @@ class TestEvaluate(base.TestEvaluatorBase):
for alarm in self.alarms:
alarm.rule[field] = value
def setUp(self):
super(TestEvaluate, self).setUp()
self.evaluator._client = self.api_client
def test_retry_transient_api_failure(self):
broken = exc.CommunicationError(message='broken')
avgs = [self._get_stat('avg', self.alarms[0].rule['threshold'] - v)