Skip to content

Commit 5eb529d

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

File tree

3 files changed

+29
-1
lines changed

3 files changed

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

0 commit comments

Comments
 (0)