tests: use config fixture in evaluator tests

Change-Id: I935c4b3cd636d562bb4912953264cdf8ae5d208e
This commit is contained in:
Julien Danjou 2015-07-24 12:23:35 +02:00
parent 102f455868
commit ad2a9a2bba
3 changed files with 9 additions and 12 deletions

View File

@ -13,16 +13,17 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from oslo_config import cfg
from oslo_config import fixture
from oslotest import base
class TestEvaluatorBase(base.BaseTestCase):
def setUp(self):
super(TestEvaluatorBase, self).setUp()
self.conf = self.useFixture(fixture.Config()).conf
self.api_client = mock.Mock()
self.notifier = mock.MagicMock()
self.evaluator = self.EVALUATOR(cfg.CONF, self.notifier)
self.evaluator = self.EVALUATOR(self.conf, self.notifier)
self.storage_conn = mock.MagicMock()
self.evaluator.storage_conn = self.storage_conn
self.prepare_alarms()

View File

@ -12,12 +12,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""class for tests in aodh/evaluator/__init__.py
"""
import datetime
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslotest import base
@ -41,7 +38,7 @@ class TestEvaluatorBaseClass(base.BaseTestCase):
def evaluate(self, alarm):
pass
ev = EvaluatorSub(cfg.CONF, notifier)
ev = EvaluatorSub(mock.MagicMock(), notifier)
ev.storage_conn = mock.MagicMock()
ev._record_change = mock.MagicMock()
ev._refresh(mock.MagicMock(), mock.MagicMock(),

View File

@ -20,7 +20,6 @@ import uuid
from ceilometerclient import exc
from ceilometerclient.v2 import statistics
import mock
from oslo_config import cfg
from oslo_utils import timeutils
import pytz
from six import moves
@ -360,13 +359,13 @@ class TestEvaluate(base.TestEvaluatorBase):
def test_threshold_endpoint_types(self):
endpoint_types = ["internalURL", "publicURL"]
for endpoint_type in endpoint_types:
cfg.CONF.set_override('os_endpoint_type',
endpoint_type,
group='service_credentials')
self.conf.set_override('os_endpoint_type',
endpoint_type,
group='service_credentials')
with mock.patch('ceilometerclient.client.get_client') as client:
self.evaluator.api_client = None
self._evaluate_all_alarms()
conf = cfg.CONF.service_credentials
conf = self.conf.service_credentials
expected = [mock.call(2,
os_auth_url=conf.os_auth_url,
os_region_name=conf.os_region_name,
@ -375,7 +374,7 @@ class TestEvaluate(base.TestEvaluatorBase):
os_username=conf.os_username,
os_cacert=conf.os_cacert,
os_endpoint_type=conf.os_endpoint_type,
timeout=cfg.CONF.http_timeout,
timeout=self.conf.http_timeout,
insecure=conf.insecure)]
actual = client.call_args_list
self.assertEqual(expected, actual)