Skip to content

Commit

Permalink
add a test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshageman-stripe committed Jan 25, 2019
1 parent 56aa6b5 commit b67211f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,17 @@ def setup_stripe(self):
"api_key": stripe.api_key,
"api_version": stripe.api_version,
"enable_telemetry": stripe.enable_telemetry,
"default_http_client": stripe.default_http_client,
}
stripe.api_key = "sk_test_123"
stripe.api_version = "2017-12-14"
stripe.enable_telemetry = False
stripe.default_http_client = None
yield
stripe.api_key = orig_attrs["api_key"]
stripe.api_version = orig_attrs["api_version"]
stripe.enable_telemetry = orig_attrs["enable_telemetry"]
stripe.default_http_client = orig_attrs["default_http_client"]

@pytest.fixture
def http_client(self, mocker):
Expand Down Expand Up @@ -485,6 +488,25 @@ def test_uses_instance_account(
),
)

def test_sets_default_http_client(self, http_client):
assert not stripe.default_http_client

stripe.api_requestor.APIRequestor(client=http_client)

# default_http_client is not populated if a client is provided
assert not stripe.default_http_client

stripe.api_requestor.APIRequestor()

# default_http_client is set when no client is specified
assert stripe.default_http_client

new_default_client = stripe.default_http_client
stripe.api_requestor.APIRequestor()

# the newly created client is reused
assert stripe.default_http_client == new_default_client

def test_uses_app_info(self, requestor, mock_response, check_call):
try:
old = stripe.app_info
Expand Down

0 comments on commit b67211f

Please sign in to comment.