This repository has been archived by the owner on Feb 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Liveblog firebase notify raises on error + tests
- Loading branch information
Showing
2 changed files
with
32 additions
and
1 deletion.
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
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,30 @@ | ||
from freezegun import freeze_time | ||
from requests.exceptions import HTTPError | ||
import requests_mock | ||
|
||
from django.test import TestCase | ||
from django.test.utils import override_settings | ||
|
||
from bulbs.liveblog.tasks import firebase_update_timestamp | ||
|
||
|
||
@override_settings(LIVEBLOG_FIREBASE_NOTIFY_ENDPOINT='http://firebase.local/{liveblog_id}.json') | ||
class TestFiresbaseUpdateTimestamp(TestCase): | ||
|
||
@freeze_time('2016-08-31 12:13:14') | ||
def test_success(self): | ||
with requests_mock.mock() as mocker: | ||
mocker.put('http://firebase.local/123.json', status_code=200) | ||
|
||
firebase_update_timestamp(123) | ||
|
||
self.assertEqual(mocker.call_count, 1) | ||
self.assertEqual(mocker.request_history[0].json(), | ||
{'updatedAt': 1472645594.0}) | ||
|
||
def test_request_error(self): | ||
with requests_mock.mock() as mocker: | ||
mocker.put('http://firebase.local/123.json', status_code=500) | ||
|
||
with self.assertRaises(HTTPError): | ||
firebase_update_timestamp(123) |