Skip to content
Open
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
29 changes: 29 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Lint

on:
push:
branches:
- "master"
- "develop"
pull_request:
types: [ready_for_review, synchronize, opened]

jobs:
flake8:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.14"
- name: install dependencies
run: |
python3 -m venv venv
. venv/bin/activate
pip install .[test]
- name: run linter
run: |
. venv/bin/activate
make lint
2 changes: 1 addition & 1 deletion client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from pathlib import Path

from client.connection import Connection
from client.exceptions import ArkParameterException
from client.resource import Resource


class ArkClient(object):

def __init__(self, hostname):
Expand Down
3 changes: 2 additions & 1 deletion client/connection.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

import backoff

import requests

from client.exceptions import ArkHTTPException, ArkParameterException
from client.exceptions import ArkHTTPException


def giveup_handler(_):
Expand Down
1 change: 1 addition & 0 deletions client/resource.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flatten_dict import flatten


class Resource(object):

def __init__(self, connection):
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[flake8]
max-line-length = 100
application-import-names = client
extend-exclude = .venv,venv,build,dist

[tool:pytest]
addopts = --verbose -s
Expand Down
4 changes: 1 addition & 3 deletions tests/api/test_blocks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

import responses

from client import ArkClient
Expand Down Expand Up @@ -44,7 +42,7 @@ def test_all_calls_correct_url_with_additional_params():
)

client = ArkClient('http://127.0.0.1:4002')
client.blocks.all(page=5, limit=69, orderBy="timestamp.epoch", height=6838329)
client.blocks.all(page=5, limit=69, orderBy='timestamp.epoch', height=6838329)
assert len(responses.calls) == 1
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/blocks?')
assert 'page=5' in responses.calls[0].request.url
Expand Down
4 changes: 1 addition & 3 deletions tests/api/test_delegates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

import responses

from client import ArkClient
Expand Down Expand Up @@ -44,7 +42,7 @@ def test_all_calls_correct_url_with_additional_params():
)

client = ArkClient('http://127.0.0.1:4002')
client.delegates.all(page=5, limit=69, orderBy="username")
client.delegates.all(page=5, limit=69, orderBy='username')
assert len(responses.calls) == 1
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/delegates?')
assert 'page=5' in responses.calls[0].request.url
Expand Down
4 changes: 1 addition & 3 deletions tests/api/test_locks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

import responses

from client import ArkClient
Expand Down Expand Up @@ -44,7 +42,7 @@ def test_all_calls_correct_url_with_additional_params():
)

client = ArkClient('http://127.0.0.1:4002')
client.locks.all(page=5, limit=69, orderBy="id")
client.locks.all(page=5, limit=69, orderBy='id')
assert len(responses.calls) == 1
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/locks?')
assert 'page=5' in responses.calls[0].request.url
Expand Down
1 change: 1 addition & 0 deletions tests/api/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def test_configuration_crypto_call_correct_url():
assert len(responses.calls) == 1
assert responses.calls[0].request.url == 'http://127.0.0.1:4002/node/configuration/crypto'


def test_fees_calls_correct_url():
responses.add(
responses.GET,
Expand Down
2 changes: 0 additions & 2 deletions tests/api/test_rounds.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

import responses

from client import ArkClient
Expand Down
8 changes: 5 additions & 3 deletions tests/api/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_all_calls_correct_url_with_additional_params():
)

client = ArkClient('http://127.0.0.1:4002')
client.transactions.all(page=5, limit=69, orderBy="timestamp.epoch")
client.transactions.all(page=5, limit=69, orderBy='timestamp.epoch')
assert len(responses.calls) == 1
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/transactions?')
assert 'page=5' in responses.calls[0].request.url
Expand Down Expand Up @@ -128,9 +128,11 @@ def test_all_unconfirmed_calls_correct_url_with_additional_params():
)

client = ArkClient('http://127.0.0.1:4002')
client.transactions.all_unconfirmed(page=5, limit=69, orderBy="timestamp.epoch")
client.transactions.all_unconfirmed(page=5, limit=69, orderBy='timestamp.epoch')
assert len(responses.calls) == 1
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/transactions/unconfirmed?')
assert responses.calls[0].request.url.startswith(
'http://127.0.0.1:4002/transactions/unconfirmed?'
)
assert 'page=5' in responses.calls[0].request.url
assert 'limit=69' in responses.calls[0].request.url
assert 'orderBy=timestamp.epoch' in responses.calls[0].request.url
10 changes: 5 additions & 5 deletions tests/api/test_wallets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

import responses

from client import ArkClient
Expand Down Expand Up @@ -108,7 +106,7 @@ def test_locks_calls_correct_url_with_additional_params():
)

client = ArkClient('http://127.0.0.1:4002')
client.wallets.locks(wallet_id=wallet_id, page=5, limit=69, orderBy="timestamp.epoch")
client.wallets.locks(wallet_id=wallet_id, page=5, limit=69, orderBy='timestamp.epoch')
assert len(responses.calls) == 1
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/wallets/12345/locks?')
assert 'page=5' in responses.calls[0].request.url
Expand Down Expand Up @@ -162,9 +160,11 @@ def test_transactions_calls_correct_url_with_additional_params():
)

client = ArkClient('http://127.0.0.1:4002')
client.wallets.transactions(wallet_id=wallet_id, page=5, limit=69, orderBy="timestamp.epoch")
client.wallets.transactions(wallet_id=wallet_id, page=5, limit=69, orderBy='timestamp.epoch')
assert len(responses.calls) == 1
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/wallets/12345/transactions?')
assert responses.calls[0].request.url.startswith(
'http://127.0.0.1:4002/wallets/12345/transactions?'
)
assert 'page=5' in responses.calls[0].request.url
assert 'limit=69' in responses.calls[0].request.url
assert 'orderBy=timestamp.epoch' in responses.calls[0].request.url
Expand Down
2 changes: 0 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import pytest

from client.client import ArkClient
from client.connection import Connection

Expand Down
3 changes: 2 additions & 1 deletion tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def test_connection_creation_sets_default_session_headers_and_variables():
assert isinstance(connection.session, requests.Session)
assert connection.session.headers['Content-Type'] == 'application/json'


def test_connection_request_retry_successful():
responses.add(
responses.GET,
Expand Down Expand Up @@ -46,7 +47,7 @@ def test_connection_raises_for_request_retry_failure():

connection = Connection('http://127.0.0.1:4003')

with pytest.raises(ArkHTTPException) as exception:
with pytest.raises(ArkHTTPException):
connection.get('spongebob')

assert len(responses.calls) == 3
Expand Down
1 change: 0 additions & 1 deletion tests/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ def test_request_post_calls_connection_post_with_correct_params(mocker):
resource.request_post('spongebob', data={'one': 'two'}, params={'foo': 'bar'})

post_mock.assert_called_once_with('spongebob', data={'one': 'two'}, params={'foo': 'bar'})