Files
monasca-ui/monitoring/notifications/tests.py
Shinya Kawabata dee770ec47 Add support for notification plugin
This patch enable to select new notification types.
But translation notification types will be unsupported.
Note this translation constraints as bug to below launchpad,
to develop in future.

https://bugs.launchpad.net/monasca/+bug/1657673

Change-Id: I47dd187d2efc71a53d64307821b0420a00935bc0
2017-01-19 17:25:38 +09:00

53 lines
1.8 KiB
Python

from django.core import urlresolvers
from mock import patch, call # noqa
from monitoring.test import helpers
from monitoring.notifications import constants
INDEX_URL = urlresolvers.reverse(
constants.URL_PREFIX + 'index')
CREATE_URL = urlresolvers.reverse(
constants.URL_PREFIX + 'notification_create')
EDIT_URL = urlresolvers.reverse(
constants.URL_PREFIX + 'notification_edit', args=('12345',))
class AlarmsTest(helpers.TestCase):
def test_index(self):
with patch('monitoring.api.monitor', **{
'spec_set': ['notification_list'],
'notification_list.return_value': [],
}) as mock:
res = self.client.get(INDEX_URL)
self.assertEqual(mock.notification_list.call_count, 2)
self.assertTemplateUsed(
res, 'monitoring/notifications/index.html')
def test_notifications_create(self):
with patch('monitoring.api.monitor', **{
'spec_set': ['notification_type_list'],
'notification_type_list.return_value': [],
}) as mock:
res = self.client.get(CREATE_URL)
self.assertEqual(mock. notification_type_list.call_count, 1)
self.assertTemplateUsed(
res, 'monitoring/notifications/_create.html')
def test_notifications_edit(self):
with patch('monitoring.api.monitor', **{
'spec_set': ['notification_get', 'notification_type_list'],
'notification_get.return_value': {
'alarm_actions': []
},
'notification_type_list.return_value': [],
}) as mock:
res = self.client.get(EDIT_URL)
self.assertEqual(mock.notification_get.call_count, 1)
self.assertEqual(mock.notification_type_list.call_count, 1)
self.assertTemplateUsed(
res, 'monitoring/notifications/_edit.html')