-
Notifications
You must be signed in to change notification settings - Fork 116
/
Copy pathtest_gae_adapter.py
41 lines (30 loc) · 1.17 KB
/
test_gae_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
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import, division
import pusher
import httpretty
import sys
import os
if (sys.version_info < (2,7)):
import unittest2 as unittest
else:
import unittest
skip_test = (sys.version_info[0:2] != (2,7)) or os.environ.get("CI")
@unittest.skipIf(skip_test, "skip")
class TestGAEBackend(unittest.TestCase):
def setUp(self):
import pusher.gae
from google.appengine.api import apiproxy_stub_map, urlfetch_stub
apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
apiproxy_stub_map.apiproxy.RegisterStub('urlfetch',
urlfetch_stub.URLFetchServiceStub())
self.p = 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=%22681b0d0b1a0d1c2809180146181d1b000d1a091818460b0705%22%3E[email protected]%3C/a%3E/apps/4',%3C/div%3E%3C/div%3E%3C/div%3E%3Cdiv%20class=%22child-of-line-17%20%20react-code-text%20react-code-line-contents%22%20style=%22min-height:auto%22%3E%3Cdiv%3E%3Cdiv%20id=%22LC29%22%20class=%22react-file-line%20html-div%22%20data-testid=%22code-cell%22%20data-line-number=%2229%22%20style=%22position:relative%22%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20backend=pusher.gae.GAEBackend)
@httpretty.activate
def test_trigger_gae_success(self):
httpretty.register_uri(httpretty.POST, "http://api.pusherapp.com/apps/4/events",
body="{}",
content_type="application/json")
response = self.p.trigger(u'test_channel', u'test', {u'data': u'yolo'})
self.assertEqual(response, {})
if __name__ == '__main__':
unittest.main()