diff --git a/tests/test_email_notification.py b/tests/test_email_notification.py index c5b1342..6833693 100644 --- a/tests/test_email_notification.py +++ b/tests/test_email_notification.py @@ -161,18 +161,17 @@ class TestEmail(base.PluginTestCase): email = _parse_email(self.trap.pop(0)) - self.assertRegexpMatches(email['from'], 'hpcs.mon@hp.com') - self.assertRegexpMatches(email['to'], 'me@here.com') - self.assertRegexpMatches(email['raw'], 'Content-Type: text/plain') - self.assertRegexpMatches(email['raw'], - 'Content-Transfer-Encoding: base64') - self.assertRegexpMatches(email['subject'], - 'ALARM LOW "test Alarm .*" for Host: foo1.*') - self.assertRegexpMatches(email['body'], 'Alarm .test Alarm.') - self.assertRegexpMatches(email['body'], 'On host .foo1.') - self.assertRegexpMatches(email['body'], UNICODE_CHAR) - self.assertRegexpMatches(email['body'], 'Link: some-link') - self.assertRegexpMatches(email['body'], 'Lifecycle state: OPEN') + self.assertRegex(email['from'], 'hpcs.mon@hp.com') + self.assertRegex(email['to'], 'me@here.com') + self.assertRegex(email['raw'], 'Content-Type: text/plain') + self.assertRegex(email['raw'], 'Content-Transfer-Encoding: base64') + self.assertRegex(email['subject'], + 'ALARM LOW "test Alarm .*" for Host: foo1.*') + self.assertRegex(email['body'], 'Alarm .test Alarm.') + self.assertRegex(email['body'], 'On host .foo1.') + self.assertRegex(email['body'], UNICODE_CHAR) + self.assertRegex(email['body'], 'Link: some-link') + self.assertRegex(email['body'], 'Lifecycle state: OPEN') return_value = self.trap.pop(0) self.assertTrue(return_value) @@ -191,16 +190,15 @@ class TestEmail(base.PluginTestCase): email = _parse_email(self.trap.pop(0)) - self.assertRegexpMatches(email['from'], 'hpcs.mon@hp.com') - self.assertRegexpMatches(email['to'], 'me@here.com') - self.assertRegexpMatches(email['raw'], 'Content-Type: text/plain') - self.assertRegexpMatches(email['raw'], - 'Content-Transfer-Encoding: base64') - self.assertRegexpMatches(email['subject'], - 'ALARM LOW .test Alarm.* Target: some_where') - self.assertRegexpMatches(email['body'], "Alarm .test Alarm.") - self.assertRegexpMatches(email['body'], "On host .foo1.") - self.assertRegexpMatches(email['body'], UNICODE_CHAR) + self.assertRegex(email['from'], 'hpcs.mon@hp.com') + self.assertRegex(email['to'], 'me@here.com') + self.assertRegex(email['raw'], 'Content-Type: text/plain') + self.assertRegex(email['raw'], 'Content-Transfer-Encoding: base64') + self.assertRegex(email['subject'], + 'ALARM LOW .test Alarm.* Target: some_where') + self.assertRegex(email['body'], "Alarm .test Alarm.") + self.assertRegex(email['body'], "On host .foo1.") + self.assertRegex(email['body'], UNICODE_CHAR) return_value = self.trap.pop(0) self.assertTrue(return_value) @@ -219,15 +217,15 @@ class TestEmail(base.PluginTestCase): email = _parse_email(self.trap.pop(0)) - self.assertRegexpMatches(email['from'], "From: hpcs.mon@hp.com") - self.assertRegexpMatches(email['to'], "To: me@here.com") - self.assertRegexpMatches(email['raw'], "Content-Type: text/plain") - self.assertRegexpMatches(email['subject'], "Subject: ALARM LOW .test Alarm.") - self.assertRegexpMatches(email['body'], "Alarm .test Alarm.") - self.assertRegexpMatches(email['body'], "foo1") - self.assertRegexpMatches(email['body'], "foo2") - self.assertRegexpMatches(email['body'], "bar1") - self.assertRegexpMatches(email['body'], "bar2") + self.assertRegex(email['from'], "From: hpcs.mon@hp.com") + self.assertRegex(email['to'], "To: me@here.com") + self.assertRegex(email['raw'], "Content-Type: text/plain") + self.assertRegex(email['subject'], "Subject: ALARM LOW .test Alarm.") + self.assertRegex(email['body'], "Alarm .test Alarm.") + self.assertRegex(email['body'], "foo1") + self.assertRegex(email['body'], "foo2") + self.assertRegex(email['body'], "bar1") + self.assertRegex(email['body'], "bar2") return_value = self.trap.pop(0) self.assertTrue(return_value) diff --git a/tests/test_notification_processor.py b/tests/test_notification_processor.py index 605a949..92fd009 100644 --- a/tests/test_notification_processor.py +++ b/tests/test_notification_processor.py @@ -126,8 +126,8 @@ class TestNotificationProcessor(base.BaseTestCase): for msg in self.trap: if "From: hpcs.mon@hp.com" in msg: - self.assertRegexpMatches(msg, "From: hpcs.mon@hp.com") - self.assertRegexpMatches(msg, "To: me@here.com") - self.assertRegexpMatches(msg, "Content-Type: text/plain") - self.assertRegexpMatches(msg, "Alarm .test Alarm.") - self.assertRegexpMatches(msg, "On host .foo1.") + self.assertRegex(msg, "From: hpcs.mon@hp.com") + self.assertRegex(msg, "To: me@here.com") + self.assertRegex(msg, "Content-Type: text/plain") + self.assertRegex(msg, "Alarm .test Alarm.") + self.assertRegex(msg, "On host .foo1.") diff --git a/tests/test_pagerduty_notification.py b/tests/test_pagerduty_notification.py index cd1f126..987e3fb 100644 --- a/tests/test_pagerduty_notification.py +++ b/tests/test_pagerduty_notification.py @@ -134,9 +134,9 @@ class TestPagerduty(base.PluginTestCase): self.assertEqual(details['message'], 'I am alarming!') def pagerduty_http_error(self, log_msg, http_response): - self.assertRegexpMatches(log_msg, "Error with pagerduty request.") - self.assertRegexpMatches(log_msg, "key=") - self.assertRegexpMatches(log_msg, "response=%s" % http_response) + self.assertRegex(log_msg, "Error with pagerduty request.") + self.assertRegex(log_msg, "key=") + self.assertRegex(log_msg, "response=%s" % http_response) @mock.patch('monasca_notification.plugins.pagerduty_notifier.requests') def notify(self, http_func, mock_requests): @@ -277,8 +277,8 @@ class TestPagerduty(base.PluginTestCase): results = self.trap.get(timeout=1) - self.assertRegexpMatches(results, "Exception on pagerduty request") - self.assertRegexpMatches(results, "key=") + self.assertRegex(results, "Exception on pagerduty request") + self.assertRegex(results, "key=") return_value = self.trap.get() self.assertFalse(return_value) diff --git a/tests/test_webhook_notification.py b/tests/test_webhook_notification.py index f9effc7..cd386d1 100644 --- a/tests/test_webhook_notification.py +++ b/tests/test_webhook_notification.py @@ -128,11 +128,11 @@ class TestWebhook(base.PluginTestCase): error = self.trap.get() - self.assertNotRegexpMatches(error, "alarm_id.: .test Alarm") - self.assertNotRegexpMatches(error, "content-type.: .application/json") + self.assertNotRegex(error, "alarm_id.: .test Alarm") + self.assertNotRegex(error, "content-type.: .application/json") - self.assertRegexpMatches(error, "HTTP code 404") - self.assertRegexpMatches(error, "post on URL http://mock:3333/") + self.assertRegex(error, "HTTP code 404") + self.assertRegex(error, "post on URL http://mock:3333/") return_value = self.trap.get() self.assertFalse(return_value) @@ -150,10 +150,10 @@ class TestWebhook(base.PluginTestCase): result = self.trap.get() - self.assertNotRegexpMatches(result, "alarm_id.: .test Alarm") - self.assertNotRegexpMatches(result, "content-type.: .application/json") + self.assertNotRegex(result, "alarm_id.: .test Alarm") + self.assertNotRegex(result, "content-type.: .application/json") - self.assertRegexpMatches(result, "Error trying to post on URL http://mock:3333/") + self.assertRegex(result, "Error trying to post on URL http://mock:3333/") return_value = self.trap.get() self.assertFalse(return_value)