From a60027742b2668a71ad9c0955e7a3381e2f90dfd Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:18:44 +0000 Subject: [PATCH 1/3] chore: update dependencies mainsail --- .github/workflows/test.yml | 6 ++--- README.md | 10 ++------ requirements.txt | 50 +++++++++++++++++++------------------- setup.cfg | 3 --- setup.py | 28 +++++++++------------ 5 files changed, 42 insertions(+), 55 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 45a2d13..c937bb1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,12 +14,12 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] + python-version: ["3.11", "3.12", "3.13", "3.14"] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v7 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} - name: install dependencies diff --git a/README.md b/README.md index 2622cab..692b001 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ If you have any questions, requests or ideas open an issue or ask us in #python ### Prerequisites -- Python >= 3.8 +- Python >= 3.11 ### Setup @@ -74,19 +74,13 @@ pip install -r requirements.txt Run the following command to install the package in development mode: ```bash -python setup.py develop +pip install -e . ``` 6. Run the tests Use pytest to run the tests and ensure everything is working correctly: -```bash -python setup.py test -``` - -Or directly with pytest: - ```bash pytest ``` diff --git a/requirements.txt b/requirements.txt index c7f3ce8..3cd220e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,26 +1,26 @@ backoff==2.2.1 -certifi==2024.6.2 -chardet==3.0.4 -charset-normalizer==3.3.2 -coverage==7.5.3 -flake8==3.5.0 -flake8-import-order==0.17.1 -flake8-print==3.1.0 -flake8-quotes==1.0.0 -flatten-dict==0.4.2 -idna==2.7 -iniconfig==2.0.0 -mccabe==0.6.1 -packaging==24.1 -pluggy==1.5.0 -pycodestyle==2.3.1 -pyflakes==1.6.0 -pytest==8.2.2 -pytest-cov==2.5.1 -pytest-mock==1.10.0 -pytest-responses==0.5.1 -requests==2.32.3 -responses==0.10.15 -setuptools==70.1.0 -six==1.16.0 -urllib3==2.2.2 +certifi==2026.11.20 +charset-normalizer==3.5.3 +coverage==7.18.0 +flake8==7.5.0 +flake8-import-order==0.19.2 +flake8-print==5.0.0 +flake8-quotes==3.4.0 +flatten-dict==0.6.0 +idna==3.20 +iniconfig==2.3.1 +mccabe==0.7.0 +packaging==26.4 +pluggy==1.7.0 +pycodestyle==2.15.0 +pyflakes==4.1.0 +pygments==2.21.0 +pytest==9.2.0 +pytest-cov==7.1.0 +pytest-mock==3.17.0 +pytest-responses==0.6.0 +pyyaml==6.0.4 +requests==2.34.2 +responses==0.26.3 +setuptools==84.2.1 +urllib3==2.8.0 diff --git a/setup.cfg b/setup.cfg index 36dfa98..dded69d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,3 @@ -[aliases] -test=pytest - [flake8] max-line-length = 100 application-import-names = client diff --git a/setup.py b/setup.py index 46100de..0f2c100 100644 --- a/setup.py +++ b/setup.py @@ -1,22 +1,21 @@ -import sys - import setuptools requires = [ - 'requests==2.32.3', 'backoff==2.2.1', - 'flatten-dict==0.4.2', + 'flatten-dict==0.6.0', + 'requests==2.34.2', ] tests_require = [ - 'pytest==8.2.2', - 'pytest-cov==2.5.1', - 'pytest-mock==1.10.0', - 'pytest-responses==0.5.1', - 'flake8==3.5.0', - 'flake8-import-order==0.17.1', - 'flake8-print==3.1.0', - 'flake8-quotes==1.0.0', + 'flake8==7.5.0', + 'flake8-import-order==0.19.2', + 'flake8-print==5.0.0', + 'flake8-quotes==3.4.0', + 'pytest==9.2.0', + 'pytest-cov==7.1.0', + 'pytest-mock==3.17.0', + 'pytest-responses==0.6.0', + 'responses==0.26.3', ] extras_require = { @@ -24,8 +23,6 @@ 'dev': requires + tests_require } -setup_requires = ['pytest-runner'] if {'pytest', 'test', 'ptr'}.intersection(sys.argv) else [] - setuptools.setup( name='arkecosystem-client', description='A simple Python API client for the ARK Blockchain.', @@ -34,8 +31,7 @@ author_email='info@client.io', url='https://github.com/ArkEcosystem/python-client', packages=setuptools.find_packages(exclude=['tests', 'tests.*']), + python_requires='>=3.11', install_requires=requires, extras_require=extras_require, - tests_require=tests_require, - setup_requires=setup_requires, ) From a55b75d497acac3732129e11a09eb9bd50729337 Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Tue, 1 Dec 2026 16:10:35 +0000 Subject: [PATCH 2/3] test: fix broken and missing assertions --- tests/test_client.py | 3 +++ tests/test_connection.py | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_client.py b/tests/test_client.py index 4543f27..0b7ed79 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -11,10 +11,13 @@ def test_client(): assert hasattr(client, 'blockchain') == True assert hasattr(client, 'blocks') == True assert hasattr(client, 'commits') == True + assert hasattr(client, 'contracts') == True assert hasattr(client, 'evm') == True assert hasattr(client, 'node') == True assert hasattr(client, 'peers') == True + assert hasattr(client, 'receipts') == True assert hasattr(client, 'rounds') == True + assert hasattr(client, 'tokens') == True assert hasattr(client, 'transactions') == True assert hasattr(client, 'validators') == True assert hasattr(client, 'votes') == True diff --git a/tests/test_connection.py b/tests/test_connection.py index 26dbf07..5a54fce 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -147,7 +147,7 @@ def test_http_methods_call_correct_url_and_return_correct_response(method, func_ @pytest.mark.parametrize('method,func_name', [ (responses.GET, 'get'), - # (responses.POST, 'post'), + (responses.POST, 'post'), ]) def test_http_methods_call_correct_url_with_params_and_return_correct_response(method, func_name): responses.add( @@ -171,11 +171,9 @@ def test_session_detects_hostname_correctly(): def test_session_throws_error_when_missing_hostname(): - with pytest.raises(ValueError) as exception: + with pytest.raises(ValueError, match='hostname is required'): Session() - assert exception.value == 'hostname is required' - def test_session_prepends_hostname_to_url(): responses.add( From 21d148a4f2090cd955588bfc3e00c328f3acc13a Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Tue, 1 Dec 2026 16:10:35 +0000 Subject: [PATCH 3/3] test: cover params flattening and host routing --- tests/api/test_evm.py | 6 +++++- tests/api/test_transactions.py | 6 +++++- tests/test_client.py | 29 ++++++++++++++++++++++++++++- tests/test_connection.py | 9 +++++++++ tests/test_resource.py | 26 ++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 3 deletions(-) diff --git a/tests/api/test_evm.py b/tests/api/test_evm.py index a3d1876..9863d30 100644 --- a/tests/api/test_evm.py +++ b/tests/api/test_evm.py @@ -12,7 +12,11 @@ def test_eth_call_methods_correct_url(): status=200 ) - client = Client('http://127.0.0.1:4002/evm/api') + client = Client({ + 'api': 'http://127.0.0.1:4002/api', + 'transactions': None, + 'evm': 'http://127.0.0.1:4002/evm/api', + }) client.evm.call({ 'method': 'eth_call', 'params': [[{ 'random': 'data' }], 'latest'], diff --git a/tests/api/test_transactions.py b/tests/api/test_transactions.py index ad39204..decbfbb 100644 --- a/tests/api/test_transactions.py +++ b/tests/api/test_transactions.py @@ -53,7 +53,11 @@ def test_create_calls_correct_url_with_data(): status=200 ) - client = Client('http://127.0.0.1:4002/tx/api') + client = Client({ + 'api': 'http://127.0.0.1:4002/api', + 'transactions': 'http://127.0.0.1:4002/tx/api', + 'evm': None, + }) client.transactions.create([{'random': 'data'}]) assert len(responses.calls) == 1 assert responses.calls[0].request.url == ( diff --git a/tests/test_client.py b/tests/test_client.py index 0b7ed79..f2ed249 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1,4 +1,4 @@ -import pytest +import responses from client.client import Client @@ -22,3 +22,30 @@ def test_client(): assert hasattr(client, 'validators') == True assert hasattr(client, 'votes') == True assert hasattr(client, 'wallets') == True + + +def test_client_switches_back_to_api_host_after_using_another_endpoint(): + responses.add( + responses.POST, + 'http://127.0.0.1:4002/tx/api/transactions', + json={'success': True}, + status=200 + ) + responses.add( + responses.GET, + 'http://127.0.0.1:4002/api/wallets', + json={'success': True}, + status=200 + ) + + client = Client({ + 'api': 'http://127.0.0.1:4002/api', + 'transactions': 'http://127.0.0.1:4002/tx/api', + 'evm': None, + }) + client.transactions.create([{'random': 'data'}]) + client.wallets.all() + + assert len(responses.calls) == 2 + assert responses.calls[0].request.url == 'http://127.0.0.1:4002/tx/api/transactions' + assert responses.calls[1].request.url == 'http://127.0.0.1:4002/api/wallets' diff --git a/tests/test_connection.py b/tests/test_connection.py index 5a54fce..f9f68ff 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -41,6 +41,15 @@ def test_connection_with_hosts_dict(): assert connection.session.hostname == 'http://127.0.0.1:4003/api' +@pytest.mark.parametrize('endpoint', ['transactions', 'evm']) +def test_connection_with_endpoint_falls_back_to_api_host_when_not_set(endpoint): + connection = Connection('http://127.0.0.1:4003/api') + + connection.with_endpoint(endpoint) + + assert connection.session.hostname == 'http://127.0.0.1:4003/api' + + def test_connection_request_retry_successful(): responses.add( responses.GET, diff --git a/tests/test_resource.py b/tests/test_resource.py index 8b22eec..d062ebc 100644 --- a/tests/test_resource.py +++ b/tests/test_resource.py @@ -21,3 +21,29 @@ def test_request_post_calls_connection_post_with_correct_params(mocker): post_mock.assert_called_once_with('spongebob', data={'one': 'two'}, params={'foo': 'bar'}) + +def test_request_get_flattens_nested_params_with_dot_notation(mocker): + get_mock = mocker.patch.object(Connection, 'get') + connection = Connection('http://127.0.0.1:4003') + + resource = Resource(connection) + resource.request_get('spongebob', params={'height': {'from': 1, 'to': 10}, 'page': 2}) + + get_mock.assert_called_once_with( + 'spongebob', + params={'height.from': 1, 'height.to': 10, 'page': 2}, + ) + + +def test_request_post_flattens_nested_params_with_dot_notation(mocker): + post_mock = mocker.patch.object(Connection, 'post') + connection = Connection('http://127.0.0.1:4003') + + resource = Resource(connection) + resource.request_post('spongebob', data={'one': {'two': 'three'}}, params={'foo': {'bar': 1}}) + + post_mock.assert_called_once_with( + 'spongebob', + data={'one': {'two': 'three'}}, + params={'foo.bar': 1}, + )