Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/pushes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and release

'on':
push:
branches:
- master
pull_request:
types:
- opened
- synchronize

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- name: Checkout the repo
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install poetry
run: |
pip install --upgrade pip
pip install poetry
python -V
pip -V
poetry -V
poetry config virtualenvs.create false
shell: bash

- name: poetry install
run: poetry install --verbose
shell: bash

- name: Lint
run: poetry run black --check .
shell: bash

- name: Test
run: poetry run pytest -vvv tests
shell: bash
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

1,431 changes: 853 additions & 578 deletions poetry.lock

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9"
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13"
]

[tool.poetry.dependencies]
Expand Down
6 changes: 2 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def setUp(self):
}
}
self.response_mock = response_mock
self.expected_output = u"""{
self.expected_output = """{
"url": "https://api.trustpilot.com/v1/business-units/5400267300006400057a0113/reviews",
"status": 401,
"content": {
Expand All @@ -62,7 +62,7 @@ def setUp(self):
}
}
"""
self.expected_verbose_output = u"""{
self.expected_verbose_output = """{
"url": "https://api.trustpilot.com/v1/business-units/5400267300006400057a0113/reviews",
"status": 401,
"headers": {
Expand Down Expand Up @@ -106,7 +106,6 @@ def test_create_access_token(self, client_mock):
@mock.patch("trustpilot.cli.client", autospec=True)
@mock.patch("trustpilot.cli.auth")
def test_no_verbosity_with_get(self, auth_mock, client_mock):

client_mock.get.return_value = self.response_mock

result = self.runner.invoke(
Expand Down Expand Up @@ -278,7 +277,6 @@ def assert_output_equal(self, output, expected_output):
@mock.patch("trustpilot.cli.client", autospec=True)
@mock.patch("trustpilot.cli.auth")
def test_no_verbosity_with_get(self, auth_mock, client_mock):
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test test_no_verbosity_with_get is defined twice in this file, which causes the first definition to be overridden. Please remove or rename the duplicate to avoid unexpected test behavior.

Suggested change
def test_no_verbosity_with_get(self, auth_mock, client_mock):
def test_no_verbosity_with_get_first(self, auth_mock, client_mock):

Copilot uses AI. Check for mistakes.

client_mock.get.return_value = self.response_mock

result = self.runner.invoke(
Expand Down
2 changes: 0 additions & 2 deletions trustpilot/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def setup(
user_agent=None,
**kwargs
):

self.api_host = api_host or environ.get(
"TRUSTPILOT_API_HOST", "https://api.trustpilot.com"
)
Expand Down Expand Up @@ -113,7 +112,6 @@ async def post(self, url, *args, **kwargs):
return await self.authenticated_request("post", url, *args, **kwargs)

async def get(self, url, *args, **kwargs):

return await self.authenticated_request("get", url, *args, **kwargs)

async def put(self, url, *args, **kwargs):
Expand Down
6 changes: 4 additions & 2 deletions trustpilot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def setup(
user_agent=None,
**kwargs
):

self.api_host = api_host or environ.get(
"TRUSTPILOT_API_HOST", "https://api.trustpilot.com"
)
Expand Down Expand Up @@ -112,7 +111,10 @@ def _post_request_callback(self, response, *args, **kwargs):
req = response.request
retry = getattr(req, "authentication_retry", True)

if retry and response.status_code in (requests.codes.unauthorized, requests.codes.forbidden):
if retry and response.status_code in (
requests.codes.unauthorized,
requests.codes.forbidden,
):
logger.debug(
{"message": "reauthenticating and retrying once", "url": req.url}
)
Expand Down