Skip to content

Commit

Permalink
Reverted bug and updated README and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanballs committed Feb 25, 2015
1 parent dec3f27 commit 2d499fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ Cabot Email alert Plugin
This is an alert plugin for the cabot service monitoring tool. It allows you to alert users by email.

## Installation
Enter the cabot virtual environment.
$ pip install cabot-alert-hipchat
$ foreman stop
Add cabot_alert_email to the installed apps in settings.py
$ foreman run python manage.py syncdb
$ foreman start
cabot_alert_email should come installed with cabot as default however if you need to install it manually, append

cabot_alert_email

to the variable

CABOT_PLUGINS_ENABLED

in your

conf/production.env
4 changes: 2 additions & 2 deletions cabot_alert_email/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class EmailAlert(AlertPlugin):
author = "Jonathan Balls"

def send_alert(self, service, users, duty_officers):
emails = [u.user.email for u in users]
emails = [u.email for u in users if u.email]
if not emails:
return
c = Context({
Expand All @@ -36,7 +36,7 @@ def send_alert(self, service, users, duty_officers):
})
if service.overall_status != service.PASSING_STATUS:
if service.overall_status == service.CRITICAL_STATUS:
emails += [u.email for u in duty_officers]
emails += [u.email for u in users if u.email]
subject = '%s status for service: %s' % (
service.overall_status, service.name)
else:
Expand Down
4 changes: 2 additions & 2 deletions cabot_alert_email/tests/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def test_send_mail(self, fake_send_mail):
self.service.alert()
fake_send_mail.assert_called_with(message=u'Service Service http://localhost/service/1/ is back to normal.\n\n', subject='Service back to normal: Service', recipient_list=[u'test@userprofile.co.uk'], from_email='Cabot <cabot@example.com>')

@patch('cabot_alert_email.models.send_mail'
) def test_failure_alert(self, fake_send_mail):
@patch('cabot_alert_email.models.send_mail')
def test_failure_alert(self, fake_send_mail):
# Most recent failed
self.service.overall_status = Service.CALCULATED_FAILING_STATUS
self.service.old_overall_status = Service.PASSING_STATUS
Expand Down

0 comments on commit 2d499fd

Please sign in to comment.