File tree Expand file tree Collapse file tree 1 file changed +68
-0
lines changed Expand file tree Collapse file tree 1 file changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,74 @@ def test_publish_to_interests_should_make_correct_http_request(self):
83
83
},
84
84
)
85
85
86
+ def test_enabling_proxies_should_not_fail (self ):
87
+ pn_client = PushNotifications (
88
+ 'INSTANCE_ID' ,
89
+ 'SECRET_KEY' ,
90
+ use_proxy_env_vars = True ,
91
+ )
92
+ with requests_mock .Mocker () as http_mock :
93
+ http_mock .register_uri (
94
+ requests_mock .ANY ,
95
+ requests_mock .ANY ,
96
+ status_code = 200 ,
97
+ json = {
98
+ 'publishId' : '1234' ,
99
+ },
100
+ )
101
+ response = pn_client .publish_to_interests (
102
+ interests = ['donuts' ],
103
+ publish_body = {
104
+ 'apns' : {
105
+ 'aps' : {
106
+ 'alert' : 'Hello World!' ,
107
+ },
108
+ },
109
+ },
110
+ )
111
+ req = http_mock .request_history [0 ]
112
+
113
+ method = req .method
114
+ path = req .path
115
+ headers = dict (req ._request .headers .lower_items ())
116
+ body = req .json ()
117
+
118
+ self .assertEqual (
119
+ method ,
120
+ 'POST' ,
121
+ )
122
+ self .assertEqual (
123
+ path ,
124
+ '/publish_api/v1/instances/instance_id/publishes/interests' ,
125
+ )
126
+ self .assertDictEqual (
127
+ headers ,
128
+ {
129
+ 'content-type' : 'application/json' ,
130
+ 'content-length' : '69' ,
131
+ 'authorization' : 'Bearer SECRET_KEY' ,
132
+ 'x-pusher-library' : 'pusher-push-notifications-python 1.1.0' ,
133
+ 'host' : 'instance_id.pushnotifications.pusher.com' ,
134
+ },
135
+ )
136
+ self .assertDictEqual (
137
+ body ,
138
+ {
139
+ 'interests' : ['donuts' ],
140
+ 'apns' : {
141
+ 'aps' : {
142
+ 'alert' : 'Hello World!' ,
143
+ },
144
+ },
145
+ },
146
+ )
147
+ self .assertDictEqual (
148
+ response ,
149
+ {
150
+ 'publishId' : '1234' ,
151
+ },
152
+ )
153
+
86
154
def test_deprecated_alias_still_works (self ):
87
155
pn_client = PushNotifications (
88
156
'INSTANCE_ID' ,
You can’t perform that action at this time.
0 commit comments