Merge "Patch-notification failed with period=0" into stable/newton

This commit is contained in:
Jenkins 2017-01-05 07:04:21 +00:00 committed by Gerrit Code Review
commit 726bcf38e2
2 changed files with 63 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# (C) Copyright 2014-2016 Hewlett Packard Enterprise Development Company LP
# (C) Copyright 2014-2016 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -279,6 +279,66 @@ class ShellTestMonascaCommands(ShellBase):
retvalue = self.shell(argstr)
self.assertRegexpMatches(retvalue, "id")
def test_good_notifications_patch(self):
self._script_keystone_client()
id_str = '0495340b-58fd-4e1c-932b-5e6f9cc96490'
resp = fakes.FakeHTTPResponse(
201,
'Created',
{'location': 'http://no.where/v2.0/notification-methods'},
None)
http.HTTPClient.json_request(
'PATCH',
'/notification-methods/' + id_str,
data={'type': 'EMAIL',
'address': 'john.doe@hpe.com',
'period': 0},
headers={'X-Auth-Key': 'password',
'X-Auth-User': 'username'}).AndReturn((resp, 'id'))
self.m.ReplayAll()
argstring = 'notification-patch {0} --type EMAIL --address' \
' john.doe@hpe.com --period 0'.format(id_str)
retvalue = self.shell(argstring)
self.assertRegexpMatches(retvalue, "id")
def test_bad_notifications_patch(self):
self._script_keystone_client()
id_str = '0495340b-58fd-4e1c-932b-5e6f9cc96490'
argstring = 'notification-patch {0} --type EMAIL --address' \
' john.doe@hpe.com --period 60'.format(id_str)
self.m.ReplayAll()
retvalue = self.shell(argstring)
self.assertRegexpMatches(retvalue, "^Invalid")
def test_good_notifications_update(self):
self._script_keystone_client()
id_str = '0495340b-58fd-4e1c-932b-5e6f9cc96491'
resp = fakes.FakeHTTPResponse(
201,
'Created',
{'location': 'http://no.where/v2.0/notification-methods'},
None)
http.HTTPClient.json_request(
'PUT',
'/notification-methods/' + id_str,
data={'name': 'notification_updated_name',
'type': 'EMAIL',
'address': 'john.doe@hpe.com',
'period': 0},
headers={'X-Auth-Key': 'password',
'X-Auth-User': 'username'}).AndReturn((resp, 'id'))
self.m.ReplayAll()
argstring = 'notification-update {0} notification_updated_name ' \
'EMAIL john.doe@hpe.com 0'.format(id_str)
retvalue = self.shell(argstring)
self.assertRegexpMatches(retvalue, "id")
def test_good_alarm_definition_update(self):
self._script_keystone_client()

View File

@ -1,4 +1,4 @@
# (C) Copyright 2014-2016 Hewlett Packard Enterprise Development Company LP
# (C) Copyright 2014-2016 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -693,7 +693,7 @@ def do_notification_patch(mc, args):
fields['type'] = args.type
if args.address:
fields['address'] = args.address
if args.period:
if args.period or args.period == 0:
if args.type and not _validate_notification_period(
args.period, args.type.upper()):
return