Fix shell.do_alarm_get_state to get as opposed to set
Otherwise the CLI fails when attempting to set a state arg that doesn't exist. (Simple copy'n'paste error in the original code). Change-Id: Iab117177805449ddec9d03656a95a0cbbbbd58bb
This commit is contained in:
39
ceilometerclient/tests/v2/test_shell.py
Normal file
39
ceilometerclient/tests/v2/test_shell.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# 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 mock
|
||||||
|
|
||||||
|
from ceilometerclient.tests import utils
|
||||||
|
from ceilometerclient.v2 import shell as ceilometer_shell
|
||||||
|
|
||||||
|
|
||||||
|
class ShellAlarmStateCommandsTest(utils.BaseTestCase):
|
||||||
|
|
||||||
|
ALARM_ID = 'foobar'
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(ShellAlarmStateCommandsTest, self).setUp()
|
||||||
|
self.cc = mock.Mock()
|
||||||
|
self.cc.alarms = mock.Mock()
|
||||||
|
self.args = mock.Mock()
|
||||||
|
self.args.alarm_id = self.ALARM_ID
|
||||||
|
|
||||||
|
def test_alarm_state_get(self):
|
||||||
|
ceilometer_shell.do_alarm_get_state(self.cc, self.args)
|
||||||
|
self.cc.alarms.get_state.assert_called_once_with(self.ALARM_ID)
|
||||||
|
self.assertFalse(self.cc.alarms.set_state.called)
|
||||||
|
|
||||||
|
def test_alarm_state_set(self):
|
||||||
|
self.args.state = 'ok'
|
||||||
|
ceilometer_shell.do_alarm_set_state(self.cc, self.args)
|
||||||
|
self.cc.alarms.set_state.assert_called_once_with(self.ALARM_ID, 'ok')
|
||||||
|
self.assertFalse(self.cc.alarms.get_state.called)
|
||||||
@@ -423,10 +423,9 @@ def do_alarm_delete(cc, args={}):
|
|||||||
def do_alarm_set_state(cc, args={}):
|
def do_alarm_set_state(cc, args={}):
|
||||||
'''Set the state of an alarm.'''
|
'''Set the state of an alarm.'''
|
||||||
try:
|
try:
|
||||||
cc.alarms.set_state(args.alarm_id, args.state)
|
state = cc.alarms.set_state(args.alarm_id, args.state)
|
||||||
except exc.HTTPNotFound:
|
except exc.HTTPNotFound:
|
||||||
raise exc.CommandError('Alarm not found: %s' % args.alarm_id)
|
raise exc.CommandError('Alarm not found: %s' % args.alarm_id)
|
||||||
state = cc.alarms.get_state(args.alarm_id)
|
|
||||||
utils.print_dict({'state': state}, wrap=72)
|
utils.print_dict({'state': state}, wrap=72)
|
||||||
|
|
||||||
|
|
||||||
@@ -435,10 +434,9 @@ def do_alarm_set_state(cc, args={}):
|
|||||||
def do_alarm_get_state(cc, args={}):
|
def do_alarm_get_state(cc, args={}):
|
||||||
'''Get the state of an alarm.'''
|
'''Get the state of an alarm.'''
|
||||||
try:
|
try:
|
||||||
cc.alarms.set_state(args.alarm_id, args.state)
|
state = cc.alarms.get_state(args.alarm_id)
|
||||||
except exc.HTTPNotFound:
|
except exc.HTTPNotFound:
|
||||||
raise exc.CommandError('Alarm not found: %s' % args.alarm_id)
|
raise exc.CommandError('Alarm not found: %s' % args.alarm_id)
|
||||||
state = cc.alarms.get_state(args.alarm_id)
|
|
||||||
utils.print_dict({'state': state}, wrap=72)
|
utils.print_dict({'state': state}, wrap=72)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ hacking>=0.5.6,<0.8
|
|||||||
coverage>=3.6
|
coverage>=3.6
|
||||||
discover
|
discover
|
||||||
fixtures>=0.3.14
|
fixtures>=0.3.14
|
||||||
|
mock>=1.0
|
||||||
mox>=0.5.3
|
mox>=0.5.3
|
||||||
python-subunit
|
python-subunit
|
||||||
sphinx>=1.1.2
|
sphinx>=1.1.2
|
||||||
|
|||||||
Reference in New Issue
Block a user