Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[staus pages][m]: on_incident and subscribe_user methods + tests - fixes
#1 (#2) * [staus pages][m]: on_incident and subscribe_user methods + tests - fixes #1 * [code][s]: avoid need on json.dumps * v0.1.0
- Loading branch information
Showing
6 changed files
with
111 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.0.1 | ||
0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requests-mock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,34 @@ | ||
import os | ||
import unittest | ||
import requests_mock | ||
|
||
class TestApi(unittest.TestCase): | ||
def test_work(self): | ||
assert 1 == 1 | ||
from datahub_emails import api | ||
|
||
|
||
class TestStatusPage(unittest.TestCase): | ||
|
||
@requests_mock.mock() | ||
def test_on_incident_returns_none_if_comonent_not_exists(self, m): | ||
m.get('https://api.statuspage.io/v1/pages/test/components', json={}) | ||
res = api.on_incident('Test Incident', 'testing') | ||
self.assertIsNone(res) | ||
|
||
@requests_mock.mock() | ||
def test_on_incident_works(self, m): | ||
m.get('https://api.statuspage.io/v1/pages/test/components', json=[{'name': 'test', 'id': 'test'}]) | ||
m.post('https://api.statuspage.io/v1/pages/test/incidents', json={'success': True}) | ||
res = api.on_incident('Test Incident', 'test', 'errors') | ||
self.assertDictEqual(res, {'success': True}) | ||
|
||
@requests_mock.mock() | ||
def test_subscribe_user_returns_none_if_comonent_not_exists(self, m): | ||
m.get('https://api.statuspage.io/v1/pages/test/components', json={}) | ||
res = api.subscribe_user('test', 'testing@mail.com') | ||
self.assertIsNone(res) | ||
|
||
@requests_mock.mock() | ||
def test_subscribe_user_works(self, m): | ||
m.get('https://api.statuspage.io/v1/pages/test/components', json=[{'name': 'test', 'id': 'test'}]) | ||
m.post('https://api.statuspage.io/v1/pages/test/subscribers', json={'success': True}) | ||
res = api.subscribe_user('test', 'testing@mail.com') | ||
self.assertDictEqual(res, {'success': True}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters