-
Notifications
You must be signed in to change notification settings - Fork 116
/
Copy pathtest_requests_adapter.py
32 lines (23 loc) · 1011 Bytes
/
test_requests_adapter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import, division
from pusher import Pusher
import unittest
import httpretty
import sys
class TestRequestsBackend(unittest.TestCase):
def setUp(self):
# temporary ignoring warnings until these are sorted:
# https://github.com/gabrielfalcao/HTTPretty/issues/368
if sys.version_info[0] >= 3:
import warnings
warnings.filterwarnings("ignore", category=ResourceWarning, message="unclosed file <_io.BufferedRandom name*")
self.pusher = Pusher.from_url(https://github.com/u'http://key:%3Ca%20href=%22/service/https://github.com/cdn-cgi/l/email-protection%22%20class=%22__cf_email__%22%20data-cfemail=%22334056504156477352435a1d4346405b56415243431d505c5e%22%3E[email protected]%3C/a%3E/apps/4')
@httpretty.activate
def test_trigger_requests_success(self):
httpretty.register_uri(httpretty.POST, "http://api.pusherapp.com/apps/4/events",
body="{}",
content_type="application/json")
response = self.pusher.trigger(u'test_channel', u'test', {u'data': u'yolo'})
self.assertEqual(response, {})
if __name__ == '__main__':
unittest.main()