Files
openstacksdk/openstack/tests/functional/telemetry/alarm/v2/test_alarm.py
Monty Taylor a25f8f3518 Migrate to testtools for functional tests
The standard in OpenStack is to use testtools not unittest. Use the base
test class which is based on testtools. This class also sets up loggers
appropriately.

unittest has an assertEqual method that is more appropriate.
Replace use of equal comparisons to None with assertIsNone.
Replace use of setUpClass and tearDownClass with setUp and tearDown.

Change-Id: Ie0f47dc7c0905164030953ba2d2633bd095782ca
2017-11-15 09:04:00 -06:00

56 lines
1.7 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# 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 unittest
from openstack.telemetry.alarm.v2 import alarm
from openstack.tests.functional import base
@unittest.skip("bug/1524468")
class TestAlarm(base.BaseFunctionalTest):
ID = None
def setUp(self):
super(TestAlarm, self).setUp()
self.require_service('alarming')
self.require_service('metering')
self.NAME = self.getUniqueString()
meter = next(self.conn.telemetry.meters())
sot = self.conn.alarm.create_alarm(
name=self.NAME,
type='threshold',
threshold_rule={
'meter_name': meter.name,
'threshold': 1.1,
},
)
assert isinstance(sot, alarm.Alarm)
self.assertEqual(self.NAME, sot.name)
self.ID = sot.id
def tearDown(self):
sot = self.conn.alarm.delete_alarm(self.ID, ignore_missing=False)
self.assertIsNone(sot)
super(TestAlarm, self).tearDown()
def test_get(self):
sot = self.conn.alarm.get_alarm(self.ID)
self.assertEqual(self.NAME, sot.name)
self.assertEqual(self.ID, sot.id)
def test_list(self):
names = [o.name for o in self.conn.alarm.alarms()]
self.assertIn(self.NAME, names)