Skip to content

Commit

Permalink
Release: 0.2.2 (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgrayston-paddle committed Sep 4, 2024
1 parent 3ca3caf commit 96db0ed
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 11 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx&utm_medium=paddle-python-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools.

## 0.2.1 - 2024-09-19
## 0.2.2 - 2024-09-03

### Fixed

- Fixed [bug](https://github.com/PaddleHQ/paddle-python-sdk/pull/24) - set default timeout.

## 0.2.1 - 2024-08-19

### Fixed

- Fix `setup.py` version

## 0.2.0 - 2024-09-05
## 0.2.0 - 2024-08-05

### Changed

Expand Down
2 changes: 1 addition & 1 deletion paddle_billing/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def build_request_session(self) -> Session:
'Authorization': f"Bearer {self.__api_key}",
'Content-Type': 'application/json',
'Paddle-Version': str(self.use_api_version),
'User-Agent': 'PaddleSDK/python 0.2.1',
'User-Agent': 'PaddleSDK/python 0.2.2',
})

# Configure retries
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


setup(
version = '0.2.1',
version = '0.2.2',

author = 'Paddle and contributors',
author_email = 'team-dx@paddle.com',
Expand Down
30 changes: 30 additions & 0 deletions tests/Functional/Client/test_Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from requests.exceptions import RequestException, HTTPError

from tests.Utils.TestLogger import test_log_handler, LogHandler
from tests.Utils.TestClient import TestClient as UtilsTestClient


class TestClient:
Expand Down Expand Up @@ -136,3 +137,32 @@ def test_post_raw_returns_error_response(

assert test_log_handler.get_logs()[0].message == \
f"Request failed: {expected_response_status} Client Error: {expected_reason} for url: {expected_request_url}. {api_error.detail}"


def test_client_with_custom_timeout(
self,
mock_requests
):
test_client = UtilsTestClient(timeout=99)

expected_request_url = f"{test_client.base_url}/some/url"

mock_requests.post(expected_request_url, status_code=200)

test_client.client.post_raw(expected_request_url)

assert mock_requests.last_request.timeout == 99


def test_client_default_timeout(
self,
test_client,
mock_requests
):
expected_request_url = f"{test_client.base_url}/some/url"

mock_requests.post(expected_request_url, status_code=200)

test_client.client.post_raw(expected_request_url)

assert mock_requests.last_request.timeout == 60.0
20 changes: 13 additions & 7 deletions tests/Utils/TestClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ def __init__(
api_secret_key: str | None = None,
environment: Environment = Environment.SANDBOX,
logger: Logger | None = None,
timeout: float | None = None,
):
self._environment = environment
self._base_url = self._environment.base_url
self._client = client or self.create_client(api_secret_key, logger)
self._client = client or self.create_client(api_secret_key, logger, timeout)


@property
Expand All @@ -34,12 +35,17 @@ def environment(self):
return self._environment


def create_client(self, api_secret_key: str | None = None, logger: Logger | None = None):
return Client(
getenv('PADDLE_API_SECRET_KEY') if api_secret_key is None else api_secret_key,
options = Options(self._environment),
logger=logger
)
def create_client(self, api_secret_key: str | None = None, logger: Logger | None = None, timeout = None):
config = {
"api_key": getenv('PADDLE_API_SECRET_KEY') if api_secret_key is None else api_secret_key,
"options": Options(self._environment),
"logger": logger,
}

if timeout is not None:
config["timeout"] = timeout

return Client(**config)


@fixture(autouse=True)
Expand Down

0 comments on commit 96db0ed

Please sign in to comment.