Skip to content

Commit d03f99a

Browse files
committed
2.23.1
1 parent a0ab16f commit d03f99a

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.23.1
2+
* Add configuration option for custom HTTP strategies
3+
14
## 2.23.0
25
* Adds hold_in_escrow method
36
* Add error codes for verification not supported error

braintree/configuration.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ class Configuration(object):
4040
.. [1] `URL Fetch Python API Overview <https://developers.google.com/appengine/docs/python/urlfetch/overview>`_
4141
"""
4242
@staticmethod
43-
def configure(environment, merchant_id, public_key, private_key):
43+
def configure(environment, merchant_id, public_key, private_key, http_strategy=None):
4444
Configuration.environment = environment
4545
Configuration.merchant_id = merchant_id
4646
Configuration.public_key = public_key
4747
Configuration.private_key = private_key
4848
Configuration.use_unsafe_ssl = False
49+
Configuration.default_http_strategy = http_strategy
4950

5051
@staticmethod
5152
def gateway():
@@ -54,22 +55,27 @@ def gateway():
5455
@staticmethod
5556
def instantiate():
5657
return Configuration(
57-
Configuration.environment,
58-
Configuration.merchant_id,
59-
Configuration.public_key,
60-
Configuration.private_key
58+
environment=Configuration.environment,
59+
merchant_id=Configuration.merchant_id,
60+
public_key=Configuration.public_key,
61+
private_key=Configuration.private_key,
62+
http_strategy=Configuration.default_http_strategy
6163
)
6264

6365
@staticmethod
6466
def api_version():
6567
return "3"
6668

67-
def __init__(self, environment, merchant_id, public_key, private_key):
69+
def __init__(self, environment, merchant_id, public_key, private_key, http_strategy=None):
6870
self.environment = environment
6971
self.merchant_id = merchant_id
7072
self.public_key = public_key
7173
self.private_key = private_key
72-
self._http_strategy = self.__determine_http_strategy()
74+
75+
if http_strategy:
76+
self._http_strategy = http_strategy(self, self.environment)
77+
else:
78+
self._http_strategy = self.__determine_http_strategy()
7379

7480
def base_merchant_path(self):
7581
return "/merchants/" + self.merchant_id

braintree/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Version = "2.23.0"
1+
Version = "2.23.1"

tests/unit/test_configuration.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,13 @@ def test_overriding_http_strategy(self):
3939
del(os.environ["PYTHON_HTTP_STRATEGY"])
4040
else:
4141
os.environ["PYTHON_HTTP_STRATEGY"] = old_http_strategy
42+
43+
def test_configuring_with_an_http_strategy(self):
44+
old_http_strategy = Configuration.default_http_strategy
45+
46+
try:
47+
Configuration.default_http_strategy = braintree.util.http_strategy.httplib_strategy.HttplibStrategy
48+
strategy = Configuration.instantiate().http_strategy()
49+
self.assertTrue(isinstance(strategy, braintree.util.http_strategy.httplib_strategy.HttplibStrategy))
50+
finally:
51+
Configuration.default_http_strategy = old_http_strategy

0 commit comments

Comments
 (0)