本文整理汇总了Python中monasca_tempest_tests.tests.api.helpers.create_notification函数的典型用法代码示例。如果您正苦于以下问题:Python create_notification函数的具体用法?Python create_notification怎么用?Python create_notification使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_notification函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_list_notification_methods_multiple_sort_by
def test_list_notification_methods_multiple_sort_by(self):
notifications = [helpers.create_notification(
name='notification sort by 01',
type='EMAIL',
address='[email protected]',
), helpers.create_notification(
name='notification sort by 02',
type='PAGERDUTY',
address='[email protected]',
), helpers.create_notification(
name='notification sort by 03',
type='EMAIL',
address='[email protected]',
), helpers.create_notification(
name='notification sort by 04',
type='EMAIL',
address='[email protected]',
)]
for notification in notifications:
resp, response_body = self.monasca_client.create_notifications(notification)
notification['id'] = response_body['id']
resp, response_body = self.monasca_client.list_notification_methods(
'?sort_by=' + urlparse.quote('type asc,address desc,id'))
self.assertEqual(200, resp.status)
expected_order = [2, 0, 3, 1]
for i, element in enumerate(response_body['elements']):
self.assertEqual(notifications[expected_order[i]]['id'], element['id'])
for element in response_body['elements']:
self.monasca_client.delete_notification_method(element['id'])
示例2: test_create_webhook_notification_method_with_invalid_period
def test_create_webhook_notification_method_with_invalid_period(self):
notification = helpers.create_notification(type='WEBHOOK',
address='http://localhost/test01',
period=10)
self.assertRaises((exceptions.BadRequest, exceptions.UnprocessableEntity),
self.monasca_client.create_notifications,
notification)
示例3: test_create_notification_method_with_address_exceeds_max_length
def test_create_notification_method_with_address_exceeds_max_length(self):
long_address = "x" * (
constants.MAX_NOTIFICATION_METHOD_ADDRESS_LENGTH + 1)
notification = helpers.create_notification(address=long_address)
self.assertRaises(exceptions.UnprocessableEntity,
self.monasca_client.create_notifications,
notification)
示例4: test_create_pagerduty_notification_method_with_invalid_non_zero_period
def test_create_pagerduty_notification_method_with_invalid_non_zero_period(self):
notification = helpers.create_notification(type='PAGERDUTY',
address='[email protected]',
period=60)
self.assertRaises((exceptions.BadRequest, exceptions.UnprocessableEntity),
self.monasca_client.create_notifications,
notification)
示例5: test_create_notification_method
def test_create_notification_method(self):
notification = helpers.create_notification()
resp, response_body = self.monasca_client.create_notifications(
notification)
self.assertEqual(201, resp.status)
id = response_body['id']
resp, response_body = self.monasca_client.\
delete_notification_method(id)
self.assertEqual(204, resp.status)
示例6: test_create_email_notification_method_with_mixed_case_type
def test_create_email_notification_method_with_mixed_case_type(self):
notification = helpers.create_notification(name='mixed case email notification',
type='EmAil')
resp, response_body = self.monasca_client.create_notifications(
notification)
self.assertEqual(201, resp.status)
id = response_body['id']
resp, response_body = self.monasca_client.\
delete_notification_method(id)
self.assertEqual(204, resp.status)
示例7: test_create_notification_method_webhook_with_mixed_case_type
def test_create_notification_method_webhook_with_mixed_case_type(self):
notification = helpers.create_notification(type='webHooK',
address='http://mytest.test:4533')
resp, response_body = self.monasca_client.create_notifications(
notification)
self.assertEqual(201, resp.status)
id = response_body['id']
resp, response_body = self.monasca_client.\
delete_notification_method(id)
self.assertEqual(204, resp.status)
示例8: test_get_notification_method_with_invalid_id
def test_get_notification_method_with_invalid_id(self):
notification = helpers.create_notification()
resp, response_body = self.monasca_client.create_notifications(
notification)
self.assertEqual(201, resp.status)
id = data_utils.rand_name()
self.assertRaises(exceptions.NotFound,
self.monasca_client.get_notification_method,
id)
resp, response_body = self.monasca_client.\
delete_notification_method(response_body['id'])
self.assertEqual(204, resp.status)
示例9: test_patch_notification_method_with_non_int_period
def test_patch_notification_method_with_non_int_period(self):
name = data_utils.rand_name('notification-')
notification = helpers.create_notification(name=name)
resp, response_body = self.monasca_client.create_notifications(
notification)
id = response_body['id']
self.assertEqual(201, resp.status)
self.assertRaises((exceptions.BadRequest, exceptions.UnprocessableEntity),
self.monasca_client.patch_notification_method, id, period='zero')
resp, response_body = \
self.monasca_client.delete_notification_method(id)
self.assertEqual(204, resp.status)
示例10: test_patch_notification_method_address_exceeds_max_length
def test_patch_notification_method_address_exceeds_max_length(self):
name = data_utils.rand_name('notification-')
notification = helpers.create_notification(name=name)
resp, response_body = self.monasca_client.create_notifications(
notification)
id = response_body['id']
self.assertEqual(201, resp.status)
new_address_long = "x" * (
constants.MAX_NOTIFICATION_METHOD_ADDRESS_LENGTH + 1)
self.assertRaises((exceptions.BadRequest, exceptions.UnprocessableEntity),
self.monasca_client.patch_notification_method, id, address=new_address_long)
resp, response_body = \
self.monasca_client.delete_notification_method(id)
self.assertEqual(204, resp.status)
示例11: test_update_notification_method_invalid_type
def test_update_notification_method_invalid_type(self):
name = data_utils.rand_name('notification-')
notification = helpers.create_notification(name=name)
resp, response_body = self.monasca_client.create_notifications(
notification)
id = response_body['id']
self.assertEqual(201, resp.status)
self.assertRaises(exceptions.BadRequest,
self.monasca_client.update_notification_method, id,
name=response_body['name'], type='random',
address=response_body['address'])
resp, response_body = \
self.monasca_client.delete_notification_method(id)
self.assertEqual(204, resp.status)
示例12: test_create_notification_method_webhook_test_tld_and_port
def test_create_notification_method_webhook_test_tld_and_port(self):
name = data_utils.rand_name('notification-')
notification = helpers.create_notification(name=name,
type='WEBHOOK',
address='http://mytest.test:4533/webhook',
period=60)
resp, response_body = self.monasca_client.create_notifications(
notification)
self.assertEqual(201, resp.status)
id = response_body['id']
resp, response_body = self.monasca_client.\
delete_notification_method(id)
self.assertEqual(204, resp.status)
示例13: test_create_webhook_notification_method_with_non_zero_period
def test_create_webhook_notification_method_with_non_zero_period(self):
name = data_utils.rand_name('notification-')
notification = helpers.create_notification(name=name,
type='WEBHOOK',
address='http://localhost/test01',
period=60)
resp, response_body = self.monasca_client.create_notifications(
notification)
self.assertEqual(201, resp.status)
id = response_body['id']
resp, response_body = self.monasca_client.\
delete_notification_method(id)
self.assertEqual(204, resp.status)
示例14: test_update_email_notification_method_with_nonzero_period
def test_update_email_notification_method_with_nonzero_period(self):
name = data_utils.rand_name('notification-')
notification = helpers.create_notification(name=name)
resp, response_body = self.monasca_client.create_notifications(
notification)
id = response_body['id']
self.assertEqual(201, resp.status)
self.assertRaises((exceptions.BadRequest, exceptions.UnprocessableEntity),
self.monasca_client.update_notification_method, id,
name=response_body['name'], type=response_body['type'],
address=response_body['address'], period=60)
resp, response_body = \
self.monasca_client.delete_notification_method(id)
self.assertEqual(204, resp.status)
示例15: test_patch_webhook_notification_method_with_invalid_period
def test_patch_webhook_notification_method_with_invalid_period(self):
name = data_utils.rand_name('notification-')
notification = helpers.create_notification(name=name,
type='WEBHOOK',
address='http://localhost/test01',
period=60)
resp, response_body = self.monasca_client.create_notifications(
notification)
id = response_body['id']
self.assertEqual(201, resp.status)
self.assertRaises((exceptions.BadRequest, exceptions.UnprocessableEntity),
self.monasca_client.patch_notification_method, id, period=5)
resp, response_body = \
self.monasca_client.delete_notification_method(id)
self.assertEqual(204, resp.status)