Skip to content

Commit efb7702

Browse files
committed
Remove flag for proxy support (makes this a breaking change)
1 parent 9f2061a commit efb7702

File tree

2 files changed

+4
-74
lines changed

2 files changed

+4
-74
lines changed

pusher_push_notifications/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ class PushNotifications(object):
8989
This client class can be used to publish notifications to the Pusher
9090
Push Notifications service"""
9191

92-
def __init__(self, instance_id, secret_key,
93-
endpoint=None, use_proxy_env_vars=False):
92+
def __init__(self, instance_id, secret_key, endpoint=None):
9493
if not isinstance(instance_id, six.string_types):
9594
raise TypeError('instance_id must be a string')
9695
if instance_id == '':
@@ -108,7 +107,6 @@ def __init__(self, instance_id, secret_key,
108107
self.instance_id = instance_id
109108
self.secret_key = secret_key
110109
self._endpoint = endpoint
111-
self._use_proxy_env_vars = use_proxy_env_vars
112110

113111
@property
114112
def endpoint(self):
@@ -131,9 +129,9 @@ def _make_request(self, method, path, path_params, body=None):
131129
# on PythonAnywhere (a popular python deployment platform)
132130
# They require that proxy servers be loaded from the environment when
133131
# making requests (on their free plan).
134-
# This flag enables this behaviour.
135-
if self._use_proxy_env_vars:
136-
session.proxies = _get_proxies_from_env()
132+
# This reintroduces the proxy support that is the default in requests
133+
# anyway.
134+
session.proxies = _get_proxies_from_env()
137135

138136
request = requests.Request(
139137
method,

tests/test_interests.py

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -83,74 +83,6 @@ def test_publish_to_interests_should_make_correct_http_request(self):
8383
},
8484
)
8585

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-
15486
def test_deprecated_alias_still_works(self):
15587
pn_client = PushNotifications(
15688
'INSTANCE_ID',

0 commit comments

Comments
 (0)