diff options
author | ZhiQiang Fan <aji.zqfan@gmail.com> | 2016-03-08 01:43:44 +0800 |
---|---|---|
committer | ZhiQiang Fan <aji.zqfan@gmail.com> | 2016-03-10 21:43:09 +0800 |
commit | c8ff0e7f9672298859298960084721ee520fa060 (patch) | |
tree | e09b0330a12f0bd767eadab3ad0e28d38a20d824 | |
parent | b4e91a250ccd3b34f0d44732aaedee380f258e08 (diff) | |
download | python-ceilometerclient-c8ff0e7f9672298859298960084721ee520fa060.tar.gz |
remove default value of repeat-actions
I94468ff649dd4367848c74e94a3feb08494bb223 fixes problem that ceilometeclient
incorrectly reset repeat-actions when update any attribute.
I53f3af447a8f814388985f6e4ab57a8ffec18a2a reverts most of the above change,
which leading to bug 1539092. Because repeat-actions has default value False,
no matter we set it or not, it will replace this bit when we get alarm from API.
The unit test doesn't cover such case, so this change still succeeds in CI test.
We don't need to revert it again, because the redundant code for create and update
is not needed, repeat-actions has default value (False) in API side, so the proper
way is simply removing the default value in CLI side.
Change-Id: I39c28294db3e55141bb8a2024a6ddfdf8acf5e0d
Closes-Bug: #1539092
-rw-r--r-- | ceilometerclient/tests/unit/test_shell.py | 19 | ||||
-rw-r--r-- | ceilometerclient/tests/unit/v2/test_shell.py | 12 | ||||
-rw-r--r-- | ceilometerclient/v2/shell.py | 1 |
3 files changed, 31 insertions, 1 deletions
diff --git a/ceilometerclient/tests/unit/test_shell.py b/ceilometerclient/tests/unit/test_shell.py index 46b640a..6323dd5 100644 --- a/ceilometerclient/tests/unit/test_shell.py +++ b/ceilometerclient/tests/unit/test_shell.py @@ -266,3 +266,22 @@ class ShellEndpointTest(ShellTestBase): self._test_endpoint_and_token('--os-auth-token', '--os-endpoint') self._test_endpoint_and_token('--os-token', '--ceilometer-url') self._test_endpoint_and_token('--os-token', '--os-endpoint') + + +class ShellAlarmUpdateRepeatAction(ShellTestBase): + @mock.patch('ceilometerclient.v2.alarms.AlarmManager.update') + @mock.patch('ceilometerclient.v2.client.Client._get_alarm_client', + mock.Mock()) + def test_repeat_action_not_specified(self, mocked): + self.make_env(FAKE_V2_ENV) + + def _test(method): + args = ['--debug', method, '--state', 'alarm', '123'] + ceilometer_shell.main(args) + args, kwargs = mocked.call_args + self.assertEqual(None, kwargs.get('repeat_actions')) + + _test('alarm-update') + _test('alarm-threshold-update') + _test('alarm-combination-update') + _test('alarm-event-update') diff --git a/ceilometerclient/tests/unit/v2/test_shell.py b/ceilometerclient/tests/unit/v2/test_shell.py index 8f518b2..de2b5db 100644 --- a/ceilometerclient/tests/unit/v2/test_shell.py +++ b/ceilometerclient/tests/unit/v2/test_shell.py @@ -266,6 +266,18 @@ class ShellAlarmCommandTest(utils.BaseTestCase): method = ceilometer_shell.do_alarm_threshold_update self._do_test_alarm_update_repeat_actions(method, False) + def test_alarm_event_upadte_repeat_action_untouched(self): + method = ceilometer_shell.do_alarm_event_update + self._do_test_alarm_update_repeat_actions(method, None) + + def test_alarm_event_upadte_repeat_action_set(self): + method = ceilometer_shell.do_alarm_event_update + self._do_test_alarm_update_repeat_actions(method, True) + + def test_alarm_event_upadte_repeat_action_clear(self): + method = ceilometer_shell.do_alarm_event_update + self._do_test_alarm_update_repeat_actions(method, False) + @mock.patch('sys.stdout', new=six.StringIO()) def test_alarm_threshold_create_args(self): argv = ['alarm-threshold-create'] + self.THRESHOLD_ALARM_CLI_ARGS diff --git a/ceilometerclient/v2/shell.py b/ceilometerclient/v2/shell.py index 09c2e95..771ea4d 100644 --- a/ceilometerclient/v2/shell.py +++ b/ceilometerclient/v2/shell.py @@ -503,7 +503,6 @@ def common_alarm_arguments(create=False): '[timezone=<IANA Timezone>]]')) @utils.arg('--repeat-actions', dest='repeat_actions', metavar='{True|False}', type=strutils.bool_from_string, - default=False, help=('True if actions should be repeatedly notified ' 'while alarm remains in target state.')) @functools.wraps(func) |