Skip to content

Commit b0b40a5

Browse files
committed
Added tests for urlfetch adapter
1 parent ba98601 commit b0b40a5

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

pusher/urlfetch.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
division)
55

66
import urlfetch
7-
import json
87
from pusher.http import process_response
98

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

0 commit comments

Comments
 (0)