Skip to content

Commit

Permalink
Merge pull request #6 from ambitioninc/develop
Browse files Browse the repository at this point in the history
v0.2
  • Loading branch information
Micah Hausler committed Nov 11, 2014
2 parents 0183533 + 13d472c commit 448b378
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ Release Checklist

Before a new release, please go through the following checklist:

* Add a release note in docs/release_notes.rst
* Bump version in pagerduty_api/version.py
* Git tag the version
* Add a release note in docs/release_notes.rst
* Upload to pypi

Vulnerability Reporting
Expand Down
4 changes: 4 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Release Notes
=============

v0.2
----
This version fixes interaction with PagerDuty's Events API.

v0.1
----
This is the initial release of pagerduty-api.
Expand Down
19 changes: 4 additions & 15 deletions pagerduty_api/alerts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import hashlib
import json
import logging

import requests
Expand Down Expand Up @@ -102,11 +103,7 @@ def trigger(self, description, incident_key=None, client=None, client_url=None,
}
LOG.info('Triggering PagerDuty incident {0}'.format(incident_key))

response = requests.post(
url=self.URL,
data=data,
headers=self.headers
)
response = requests.post(url=self.URL, data=json.dumps(data), headers=self.headers)
return response.json()

def acknowledge(self, incident_key=None, description=None, details=None):
Expand Down Expand Up @@ -156,11 +153,7 @@ def acknowledge(self, incident_key=None, description=None, details=None):
}
LOG.info('Acknowledging PagerDuty incident {0}'.format(incident_key))

response = requests.post(
url=self.URL,
data=data,
headers=self.headers
)
response = requests.post(url=self.URL, data=json.dumps(data), headers=self.headers)
return response.json()

def resolve(self, incident_key=None, description=None, details=None):
Expand Down Expand Up @@ -210,9 +203,5 @@ def resolve(self, incident_key=None, description=None, details=None):
}
LOG.info('Resolving PagerDuty incident {0}'.format(incident_key))

response = requests.post(
url=self.URL,
data=data,
headers=self.headers
)
response = requests.post(url=self.URL, data=json.dumps(data), headers=self.headers)
return response.json()
19 changes: 10 additions & 9 deletions pagerduty_api/tests/alarm_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging

import json
import unittest
from mock import patch
import requests
Expand Down Expand Up @@ -54,18 +55,18 @@ def test_trigger_success(self, mock_post):

# Assert we made one
mock_post.assert_called_once_with(
data={
data=json.dumps({
'service_key': self.service_key,
'event_type': 'trigger',
'incident_key': self.incident_key,
'description': 'No data received',
'client': 'apple_0033c42e190872c508666ab6acbbd2e7',
'client_url': 'https://apple.ambition.com',
'details': {'some_key': 'some_value'},
},
}),
headers=self.alert.headers,
url=self.alert.URL,
)
)

@patch.object(requests, 'post')
def test_acknowledge_success(self, mock_post):
Expand All @@ -81,16 +82,16 @@ def test_acknowledge_success(self, mock_post):

# Assert we made one
mock_post.assert_called_once_with(
data={
data=json.dumps({
'service_key': self.service_key,
'event_type': 'acknowledge',
'incident_key': self.incident_key,
'description': 'No data received',
'details': {'some_key': 'some_value'},
},
}),
headers=self.alert.headers,
url=self.alert.URL,
)
)

@patch.object(requests, 'post')
def test_acknowledge_raises_error(self, mock_post):
Expand Down Expand Up @@ -120,16 +121,16 @@ def test_resolve_success(self, mock_post):

# Assert we made one
mock_post.assert_called_once_with(
data={
data=json.dumps({
'service_key': self.service_key,
'event_type': 'resolve',
'incident_key': self.incident_key,
'description': 'No data received',
'details': {'some_key': 'some_value'},
},
}),
headers=self.alert.headers,
url=self.alert.URL,
)
)

@patch.object(requests, 'post')
def test_resolve_raises_error(self, mock_post):
Expand Down
2 changes: 1 addition & 1 deletion pagerduty_api/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1'
__version__ = '0.2'
6 changes: 4 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ cover-min-percentage=100
cover-package=pagerduty_api
[flake8]
max-line-length = 120
exclude = docs,env,*.egg
max-complexity = 10
exclude = docs,env,venv,*.egg
max-complexity = 10
[bdist_wheel]
universal = 1

0 comments on commit 448b378

Please sign in to comment.