Skip to content

Commit b0970ab

Browse files
committed
Started adding tests for http adapters.
1 parent f6d0605 commit b0970ab

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from __future__ import print_function, absolute_import, division
2+
3+
import pusher
4+
import pusher.aiohttp
5+
import asyncio
6+
import unittest
7+
import httpretty
8+
9+
class TestAIOHTTPBackend(unittest.TestCase):
10+
11+
def setUp(self):
12+
self.p = pusher.Pusher.from_url(u'http://key:secret@api.pusherapp.com/apps/4',
13+
backend=pusher.aiohttp.AsyncIOBackend)
14+
15+
@httpretty.activate
16+
def test_trigger_aio_success(self):
17+
httpretty.register_uri(httpretty.POST, "http://api.pusherapp.com/apps/4/events",
18+
body="{}",
19+
content_type="application/json")
20+
response = yield from self.p.trigger(u'test_channel', u'test', {u'data': u'yolo'})
21+
self.assertEqual(response, {})
22+
23+
if __name__ == '__main__':
24+
unittest.main()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import print_function, absolute_import, division
4+
5+
from pusher import Pusher
6+
import unittest
7+
import httpretty
8+
9+
class TestRequestsBackend(unittest.TestCase):
10+
11+
def setUp(self):
12+
self.pusher = Pusher.from_url(u'http://key:secret@api.pusherapp.com/apps/4')
13+
14+
@httpretty.activate
15+
def test_trigger_requests_success(self):
16+
httpretty.register_uri(httpretty.POST, "http://api.pusherapp.com/apps/4/events",
17+
body="{}",
18+
content_type="application/json")
19+
response = self.pusher.trigger(u'test_channel', u'test', {u'data': u'yolo'})
20+
self.assertEqual(response, {})
21+
22+
if __name__ == '__main__':
23+
unittest.main()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
],
3030

3131
install_requires=['six', 'requests>=2.3.0'],
32-
tests_require=['nose', 'mock'],
32+
tests_require=['nose', 'mock', 'HTTPretty'],
3333

3434
extras_require={
3535
'aiohttp': ["aiohttp>=0.9.0"],

0 commit comments

Comments
 (0)