diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-11-28 00:20:24 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-11-28 00:20:24 +0000 |
commit | 2950b30089ab7f38b70a9dd6b40cf0823d4ade3a (patch) | |
tree | 3f81094961b2cf4016173fa83520387bace4f2b1 | |
parent | 181d913ca1415aa1ad28fb1e4ddbdd08b72a155f (diff) | |
parent | 08b476d2c9edeff7d025038467922f3d1cda6f19 (diff) | |
download | python-ceilometerclient-2950b30089ab7f38b70a9dd6b40cf0823d4ade3a.tar.gz |
Merge "Allow alarm-threshold-update to upate generic attributes"1.0.7
-rw-r--r-- | ceilometerclient/tests/v2/test_shell.py | 37 | ||||
-rw-r--r-- | ceilometerclient/v2/shell.py | 2 |
2 files changed, 33 insertions, 6 deletions
diff --git a/ceilometerclient/tests/v2/test_shell.py b/ceilometerclient/tests/v2/test_shell.py index 6fe07f8..3b24b29 100644 --- a/ceilometerclient/tests/v2/test_shell.py +++ b/ceilometerclient/tests/v2/test_shell.py @@ -172,7 +172,7 @@ class ShellAlarmCommandTest(utils.BaseTestCase): self.args = mock.Mock() self.args.alarm_id = self.ALARM_ID - def _do_test_alarm_update_repeat_actions(self, repeat_actions): + def _do_test_alarm_update_repeat_actions(self, method, repeat_actions): self.args.threshold = 42.0 if repeat_actions is not None: self.args.repeat_actions = repeat_actions @@ -183,7 +183,7 @@ class ShellAlarmCommandTest(utils.BaseTestCase): self.cc.alarms.update.return_value = alarm[0] try: - ceilometer_shell.do_alarm_update(self.cc, self.args) + method(self.cc, self.args) args, kwargs = self.cc.alarms.update.call_args self.assertEqual(self.ALARM_ID, args[0]) self.assertEqual(42.0, kwargs.get('threshold')) @@ -196,13 +196,40 @@ class ShellAlarmCommandTest(utils.BaseTestCase): sys.stdout = orig def test_alarm_update_repeat_actions_untouched(self): - self._do_test_alarm_update_repeat_actions(None) + method = ceilometer_shell.do_alarm_update + self._do_test_alarm_update_repeat_actions(method, None) def test_alarm_update_repeat_actions_set(self): - self._do_test_alarm_update_repeat_actions(True) + method = ceilometer_shell.do_alarm_update + self._do_test_alarm_update_repeat_actions(method, True) def test_alarm_update_repeat_actions_clear(self): - self._do_test_alarm_update_repeat_actions(False) + method = ceilometer_shell.do_alarm_update + self._do_test_alarm_update_repeat_actions(method, False) + + def test_alarm_combination_update_repeat_actions_untouched(self): + method = ceilometer_shell.do_alarm_combination_update + self._do_test_alarm_update_repeat_actions(method, None) + + def test_alarm_combination_update_repeat_actions_set(self): + method = ceilometer_shell.do_alarm_combination_update + self._do_test_alarm_update_repeat_actions(method, True) + + def test_alarm_combination_update_repeat_actions_clear(self): + method = ceilometer_shell.do_alarm_combination_update + self._do_test_alarm_update_repeat_actions(method, False) + + def test_alarm_threshold_update_repeat_actions_untouched(self): + method = ceilometer_shell.do_alarm_threshold_update + self._do_test_alarm_update_repeat_actions(method, None) + + def test_alarm_threshold_update_repeat_actions_set(self): + method = ceilometer_shell.do_alarm_threshold_update + self._do_test_alarm_update_repeat_actions(method, True) + + def test_alarm_threshold_update_repeat_actions_clear(self): + method = ceilometer_shell.do_alarm_threshold_update + self._do_test_alarm_update_repeat_actions(method, False) class ShellSampleListCommandTest(utils.BaseTestCase): diff --git a/ceilometerclient/v2/shell.py b/ceilometerclient/v2/shell.py index 07fd8c1..a4cec33 100644 --- a/ceilometerclient/v2/shell.py +++ b/ceilometerclient/v2/shell.py @@ -438,7 +438,7 @@ def do_alarm_threshold_update(cc, args={}): fields = utils.key_with_slash_to_nested_dict(fields) fields.pop('alarm_id') fields['type'] = 'threshold' - if 'query' in fields['threshold_rule']: + if 'threshold_rule' in fields and 'query' in fields['threshold_rule']: fields['threshold_rule']['query'] = options.cli_to_array( fields['threshold_rule']['query']) try: |