diff --git a/client/api/api_nodes.py b/client/api/api_nodes.py index 5e570f5..f4fca6a 100644 --- a/client/api/api_nodes.py +++ b/client/api/api_nodes.py @@ -3,5 +3,5 @@ class ApiNodes(Resource): - def all(self, **kwargs): - return self.with_endpoint('api').request_get('api-nodes', kwargs) + def all(self, query={}): + return self.with_endpoint('api').request_get('api-nodes', query) diff --git a/client/api/blocks.py b/client/api/blocks.py index 14628a1..2203f5b 100644 --- a/client/api/blocks.py +++ b/client/api/blocks.py @@ -3,14 +3,8 @@ class Blocks(Resource): - def all(self, page=None, limit=100, **kwargs): - extra_params = {name: kwargs[name] for name in kwargs if kwargs[name] is not None} - params = { - 'page': page, - 'limit': limit, - **extra_params - } - return self.with_endpoint('api').request_get('blocks', params) + def all(self, query={}): + return self.with_endpoint('api').request_get('blocks', query) def get(self, block_id): return self.with_endpoint('api').request_get(f'blocks/{block_id}') @@ -21,5 +15,7 @@ def first(self): def last(self): return self.with_endpoint('api').request_get('blocks/last') - def transactions(self, block_id, **kwargs): - return self.with_endpoint('api').request_get(f'blocks/{block_id}/transactions', kwargs) + def transactions(self, block_id, query={}): + return self.with_endpoint('api').request_get( + f'blocks/{block_id}/transactions', query + ) diff --git a/client/api/node.py b/client/api/node.py index 35dbf36..9bb0304 100644 --- a/client/api/node.py +++ b/client/api/node.py @@ -10,13 +10,14 @@ def syncing(self): return self.with_endpoint('api').request_get('node/syncing') def configuration(self): - return self.with_endpoint('api').request_get('node/configuration') + return self.with_endpoint('api').request_get( + 'node/configuration' + ) def crypto(self): - return self.with_endpoint('api').request_get('node/configuration/crypto') + return self.with_endpoint('api').request_get( + 'node/configuration/crypto' + ) - def fees(self, days=None): - params = { - 'days': days, - } - return self.with_endpoint('api').request_get('node/fees', params) + def fees(self, query={}): + return self.with_endpoint('api').request_get('node/fees', query) diff --git a/client/api/peers.py b/client/api/peers.py index 8699316..17c9389 100644 --- a/client/api/peers.py +++ b/client/api/peers.py @@ -3,19 +3,8 @@ class Peers(Resource): - def all(self, os=None, status=None, port=None, version=None, order_by=None, - page=None, limit=100): - - params = { - 'os': os, - 'status': status, - 'port': port, - 'version': version, - 'orderBy': order_by, - 'page': page, - 'limit': limit, - } - return self.with_endpoint('api').request_get('peers', params) + def all(self, query={}): + return self.with_endpoint('api').request_get('peers', query) def get(self, ip): return self.with_endpoint('api').request_get(f'peers/{ip}') diff --git a/client/api/receipts.py b/client/api/receipts.py index 7632832..903585a 100644 --- a/client/api/receipts.py +++ b/client/api/receipts.py @@ -2,8 +2,10 @@ class Receipts(Resource): - def all(self, **kwargs): - return self.with_endpoint('api').request_get('receipts', kwargs) + def all(self, query={}): + return self.with_endpoint('api').request_get('receipts', query) def get(self, transaction_hash: str): - return self.with_endpoint('api').request_get(f'receipts/{transaction_hash}') + return self.with_endpoint('api').request_get( + f'receipts/{transaction_hash}' + ) diff --git a/client/api/rounds.py b/client/api/rounds.py index 792aeb8..53ba93f 100644 --- a/client/api/rounds.py +++ b/client/api/rounds.py @@ -3,11 +3,13 @@ class Rounds(Resource): - def all(self, **kwargs): - return self.with_endpoint('api').request_get('rounds', kwargs) + def all(self, query={}): + return self.with_endpoint('api').request_get('rounds', query) def show(self, round_id): return self.with_endpoint('api').request_get(f'rounds/{round_id}') def validators(self, round_id): - return self.with_endpoint('api').request_get(f'rounds/{round_id}/validators') + return self.with_endpoint('api').request_get( + f'rounds/{round_id}/validators' + ) diff --git a/client/api/tokens.py b/client/api/tokens.py index a88c7ab..6ee33ad 100644 --- a/client/api/tokens.py +++ b/client/api/tokens.py @@ -3,41 +3,25 @@ class Tokens(Resource): - def all(self, page=None, limit=100): - params = { - 'page': page, - 'limit': limit, - } - return self.with_endpoint('api').request_get('tokens', params) + def all(self, query={}): + return self.with_endpoint('api').request_get('tokens', query) def get(self, address): return self.with_endpoint('api').request_get( f'tokens/{address}' ) - def holders(self, address, page=None, limit=100): - params = { - 'page': page, - 'limit': limit, - } + def holders(self, address, query={}): return self.with_endpoint('api').request_get( - f'tokens/{address}/holders', params + f'tokens/{address}/holders', query ) - def transfers_by_token(self, address, page=None, limit=100): - params = { - 'page': page, - 'limit': limit, - } + def transfers_by_token(self, address, query={}): return self.with_endpoint('api').request_get( - f'tokens/{address}/transfers', params + f'tokens/{address}/transfers', query ) - def transfers(self, page=None, limit=100): - params = { - 'page': page, - 'limit': limit, - } + def transfers(self, query={}): return self.with_endpoint('api').request_get( - 'tokens/transfers', params + 'tokens/transfers', query ) diff --git a/client/api/transactions.py b/client/api/transactions.py index 7955d73..7587a19 100644 --- a/client/api/transactions.py +++ b/client/api/transactions.py @@ -3,32 +3,32 @@ class Transactions(Resource): - def all(self, page=None, limit=100, **kwargs): - extra_params = {name: kwargs[name] for name in kwargs if kwargs[name] is not None} - params = { - 'page': page, - 'limit': limit, - **extra_params - } - return self.with_endpoint('api').request_get('transactions', params) + def all(self, query={}): + return self.with_endpoint('api').request_get( + 'transactions', query + ) def create(self, transactions): - return self.with_endpoint('transactions').request_post('transactions', data={'transactions': transactions}) + return self.with_endpoint('transactions').request_post( + 'transactions', data={'transactions': transactions} + ) def get(self, transaction_id): - return self.with_endpoint('api').request_get(f'transactions/{transaction_id}') + return self.with_endpoint('api').request_get( + f'transactions/{transaction_id}' + ) - def all_unconfirmed(self, limit=100, offset=None, **kwargs): - extra_params = {name: kwargs[name] for name in kwargs if kwargs[name] is not None} - params = { - 'limit': limit, - 'offset': offset, - **extra_params - } - return self.with_endpoint('api').request_get('transactions/unconfirmed', params) + def all_unconfirmed(self, query={}): + return self.with_endpoint('api').request_get( + 'transactions/unconfirmed', query + ) def get_unconfirmed(self, transaction_id): - return self.with_endpoint('api').request_get(f'transactions/unconfirmed/{transaction_id}') + return self.with_endpoint('api').request_get( + f'transactions/unconfirmed/{transaction_id}' + ) def configuration(self): - return self.with_endpoint('transactions').request_get('configuration') + return self.with_endpoint('transactions').request_get( + 'configuration' + ) diff --git a/client/api/validators.py b/client/api/validators.py index 741367f..eed26ab 100644 --- a/client/api/validators.py +++ b/client/api/validators.py @@ -3,20 +3,20 @@ class Validators(Resource): - def all(self, page=None, limit=100, **kwargs): - extra_params = {name: kwargs[name] for name in kwargs if kwargs[name] is not None} - params = { - 'page': page, - 'limit': limit, - **extra_params - } - return self.with_endpoint('api').request_get('validators', params) + def all(self, query={}): + return self.with_endpoint('api').request_get('validators', query) def get(self, validator_id): - return self.with_endpoint('api').request_get(f'validators/{validator_id}') + return self.with_endpoint('api').request_get( + f'validators/{validator_id}' + ) - def blocks(self, validator_id, **kwargs): - return self.with_endpoint('api').request_get(f'validators/{validator_id}/blocks', kwargs) + def blocks(self, validator_id, query={}): + return self.with_endpoint('api').request_get( + f'validators/{validator_id}/blocks', query + ) - def voters(self, validator_id, **kwargs): - return self.with_endpoint('api').request_get(f'validators/{validator_id}/voters', kwargs) + def voters(self, validator_id, query={}): + return self.with_endpoint('api').request_get( + f'validators/{validator_id}/voters', query + ) diff --git a/client/api/votes.py b/client/api/votes.py index 2986d8f..4bc7632 100644 --- a/client/api/votes.py +++ b/client/api/votes.py @@ -3,12 +3,8 @@ class Votes(Resource): - def all(self, page=None, limit=100): - params = { - 'page': page, - 'limit': limit, - } - return self.with_endpoint('api').request_get('votes', params) + def all(self, query={}): + return self.with_endpoint('api').request_get('votes', query) def get(self, vote_id): return self.with_endpoint('api').request_get(f'votes/{vote_id}') diff --git a/client/api/wallets.py b/client/api/wallets.py index 8e83e35..b070ec3 100644 --- a/client/api/wallets.py +++ b/client/api/wallets.py @@ -3,64 +3,43 @@ class Wallets(Resource): - def all(self, page=None, limit=100): - params = { - 'page': page, - 'limit': limit, - } - return self.with_endpoint('api').request_get('wallets', params) + def all(self, query={}): + return self.with_endpoint('api').request_get('wallets', query) - def top(self, page=None, limit=100): - params = { - 'page': page, - 'limit': limit - } - return self.with_endpoint('api').request_get('wallets/top', params) + def top(self, query={}): + return self.with_endpoint('api').request_get('wallets/top', query) def get(self, wallet_id): - return self.with_endpoint('api').request_get(f'wallets/{wallet_id}') - - def transactions(self, wallet_id, page=None, limit=100, **kwargs): - extra_params = {name: kwargs[name] for name in kwargs if kwargs[name] is not None} - params = { - 'page': page, - 'limit': limit, - **extra_params - } - return self.with_endpoint('api').request_get(f'wallets/{wallet_id}/transactions', params) - - def sent_transactions(self, wallet_id, page=None, limit=100): - params = { - 'page': page, - 'limit': limit, - } - return self.with_endpoint('api').request_get(f'wallets/{wallet_id}/transactions/sent', params) - - def received_transactions(self, wallet_id, page=None, limit=100): - params = { - 'page': page, - 'limit': limit, - } - return self.with_endpoint('api').request_get(f'wallets/{wallet_id}/transactions/received', params) - - def votes(self, wallet_id, page=None, limit=100): - params = { - 'page': page, - 'limit': limit, - } - return self.with_endpoint('api').request_get(f'wallets/{wallet_id}/votes', params) - - def tokens(self, wallet_id, page=None, limit=100): - params = { - 'page': page, - 'limit': limit, - } - return self.with_endpoint('api').request_get(f'wallets/{wallet_id}/tokens', params) - - def tokens_for(self, addresses, page=None, limit=100): - params = { - 'addresses': addresses, - 'page': page, - 'limit': limit, - } - return self.with_endpoint('api').request_get('wallets/tokens', params) + return self.with_endpoint('api').request_get( + f'wallets/{wallet_id}' + ) + + def transactions(self, wallet_id, query={}): + return self.with_endpoint('api').request_get( + f'wallets/{wallet_id}/transactions', query + ) + + def sent_transactions(self, wallet_id, query={}): + return self.with_endpoint('api').request_get( + f'wallets/{wallet_id}/transactions/sent', query + ) + + def received_transactions(self, wallet_id, query={}): + return self.with_endpoint('api').request_get( + f'wallets/{wallet_id}/transactions/received', query + ) + + def votes(self, wallet_id, query={}): + return self.with_endpoint('api').request_get( + f'wallets/{wallet_id}/votes', query + ) + + def tokens(self, wallet_id, query={}): + return self.with_endpoint('api').request_get( + f'wallets/{wallet_id}/tokens', query + ) + + def tokens_for(self, query={}): + return self.with_endpoint('api').request_get( + 'wallets/tokens', query + ) diff --git a/tests/api/test_api_nodes.py b/tests/api/test_api_nodes.py index 19ce9e0..4bae79f 100644 --- a/tests/api/test_api_nodes.py +++ b/tests/api/test_api_nodes.py @@ -1,4 +1,3 @@ -import json import responses from client import ArkClient @@ -14,7 +13,9 @@ def test_api_nodes_calls_correct_url(): client = ArkClient('http://127.0.0.1:4002/api') client.api_nodes.all() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/api-nodes' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/api-nodes' + ) def test_api_nodes_calls_correct_url_with_params(): @@ -26,8 +27,12 @@ def test_api_nodes_calls_correct_url_with_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.api_nodes.all(query_param1='value1', query_param2='value2') + client.api_nodes.all({ + 'query_param1': 'value1', + 'query_param2': 'value2', + }) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/api-nodes?') - assert 'query_param1=value1' in responses.calls[0].request.url - assert 'query_param2=value2' in responses.calls[0].request.url + url = responses.calls[0].request.url + assert url.startswith('http://127.0.0.1:4002/api/api-nodes?') + assert 'query_param1=value1' in url + assert 'query_param2=value2' in url diff --git a/tests/api/test_blocks.py b/tests/api/test_blocks.py index 1115c5a..6073d83 100644 --- a/tests/api/test_blocks.py +++ b/tests/api/test_blocks.py @@ -1,11 +1,9 @@ -import json - import responses from client import ArkClient -def test_all_calls_correct_url_with_default_params(): +def test_all_calls_correct_url(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/blocks', @@ -16,10 +14,12 @@ def test_all_calls_correct_url_with_default_params(): client = ArkClient('http://127.0.0.1:4002/api') client.blocks.all() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/blocks?limit=100' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/blocks' + ) -def test_all_calls_correct_url_with_passed_in_params(): +def test_all_calls_correct_url_with_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/blocks', @@ -28,29 +28,19 @@ def test_all_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.blocks.all(page=5, limit=69) - assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/blocks?') - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url - - -def test_all_calls_correct_url_with_additional_params(): - responses.add( - responses.GET, - 'http://127.0.0.1:4002/api/blocks', - json={'success': True}, - status=200 - ) - - client = ArkClient('http://127.0.0.1:4002/api') - 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/api/blocks?') - 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 - assert 'height=6838329' in responses.calls[0].request.url + url = responses.calls[0].request.url + assert url.startswith('http://127.0.0.1:4002/api/blocks?') + assert 'page=5' in url + assert 'limit=69' in url + assert 'orderBy=timestamp.epoch' in url + assert 'height=6838329' in url def test_get_calls_correct_url(): @@ -66,7 +56,9 @@ def test_get_calls_correct_url(): client.blocks.get(block_id) assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/blocks/12345' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/blocks/12345' + ) def test_first_calls_correct_url(): @@ -81,7 +73,9 @@ def test_first_calls_correct_url(): client.blocks.first() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/blocks/first' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/blocks/first' + ) def test_last_calls_correct_url(): @@ -96,24 +90,33 @@ def test_last_calls_correct_url(): client.blocks.last() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/blocks/last' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/blocks/last' + ) -def test_transactions_calls_correct_url_with_passed_in_params(): +def test_transactions_calls_correct_url_with_params(): block_id = '12345' responses.add( responses.GET, - 'http://127.0.0.1:4002/api/blocks/{}/transactions'.format(block_id), + 'http://127.0.0.1:4002/api/blocks/{}/transactions'.format( + block_id + ), json={'success': True}, status=200 ) client = ArkClient('http://127.0.0.1:4002/api') - client.blocks.transactions(block_id, page=5, limit=69, orderBy="timestamp.epoch") + client.blocks.transactions(block_id, { + 'page': 5, + 'limit': 69, + 'orderBy': 'timestamp.epoch', + }) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith( + url = responses.calls[0].request.url + assert url.startswith( 'http://127.0.0.1:4002/api/blocks/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 + assert 'page=5' in url + assert 'limit=69' in url + assert 'orderBy=timestamp.epoch' in url diff --git a/tests/api/test_node.py b/tests/api/test_node.py index bafc926..e86f0ec 100644 --- a/tests/api/test_node.py +++ b/tests/api/test_node.py @@ -14,7 +14,9 @@ def test_status_calls_correct_url(): client = ArkClient('http://127.0.0.1:4002/api') client.node.status() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/node/status' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/node/status' + ) def test_syncing_calls_correct_url(): @@ -28,7 +30,9 @@ def test_syncing_calls_correct_url(): client = ArkClient('http://127.0.0.1:4002/api') client.node.syncing() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/node/syncing' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/node/syncing' + ) def test_configuration_calls_correct_url(): @@ -42,7 +46,9 @@ def test_configuration_calls_correct_url(): client = ArkClient('http://127.0.0.1:4002/api') client.node.configuration() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/node/configuration' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/node/configuration' + ) def test_configuration_crypto_call_correct_url(): @@ -56,7 +62,10 @@ def test_configuration_crypto_call_correct_url(): client = ArkClient('http://127.0.0.1:4002/api') client.node.crypto() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/node/configuration/crypto' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/node/configuration/crypto' + ) + def test_fees_calls_correct_url(): responses.add( @@ -69,10 +78,12 @@ def test_fees_calls_correct_url(): client = ArkClient('http://127.0.0.1:4002/api') client.node.fees() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/node/fees' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/node/fees' + ) -def test_fees_calls_correct_url_with_passed_in_params(): +def test_fees_calls_correct_url_with_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/node/fees', @@ -81,7 +92,8 @@ def test_fees_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.node.fees(days=14) + client.node.fees({'days': 14}) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/node/fees?') - assert 'days=14' in responses.calls[0].request.url + url = responses.calls[0].request.url + assert url.startswith('http://127.0.0.1:4002/api/node/fees?') + assert 'days=14' in url diff --git a/tests/api/test_peers.py b/tests/api/test_peers.py index ae9f07b..f6a631a 100644 --- a/tests/api/test_peers.py +++ b/tests/api/test_peers.py @@ -3,7 +3,7 @@ from client import ArkClient -def test_all_calls_correct_url_with_default_params(): +def test_all_calls_correct_url(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/peers', @@ -14,10 +14,12 @@ def test_all_calls_correct_url_with_default_params(): client = ArkClient('http://127.0.0.1:4002/api') client.peers.all() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/peers?limit=100' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/peers' + ) -def test_all_calls_correct_url_with_passed_in_params(): +def test_all_calls_correct_url_with_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/peers', @@ -26,18 +28,25 @@ def test_all_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.peers.all( - os='a', status='live', port=1337, version='2.0.0', order_by='ip', page=5, limit=69 - ) + client.peers.all({ + 'os': 'a', + 'status': 'live', + 'port': 1337, + 'version': '2.0.0', + 'orderBy': 'ip', + 'page': 5, + 'limit': 69, + }) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/peers?') - assert 'os=a' in responses.calls[0].request.url - assert 'status=live' in responses.calls[0].request.url - assert 'port=1337' in responses.calls[0].request.url - assert 'version=2.0.0' in responses.calls[0].request.url - assert 'orderBy=ip' in responses.calls[0].request.url - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url + url = responses.calls[0].request.url + assert url.startswith('http://127.0.0.1:4002/api/peers?') + assert 'os=a' in url + assert 'status=live' in url + assert 'port=1337' in url + assert 'version=2.0.0' in url + assert 'orderBy=ip' in url + assert 'page=5' in url + assert 'limit=69' in url def test_get_calls_correct_url_with_ip(): @@ -52,4 +61,6 @@ def test_get_calls_correct_url_with_ip(): client = ArkClient('http://127.0.0.1:4002/api') client.peers.get(ip) assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/peers/123.4.5.67' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/peers/123.4.5.67' + ) diff --git a/tests/api/test_receipts.py b/tests/api/test_receipts.py index bebc330..c1e20b1 100644 --- a/tests/api/test_receipts.py +++ b/tests/api/test_receipts.py @@ -13,7 +13,9 @@ def test_all_calls_correct_url(): client = ArkClient('http://127.0.0.1:4002/api') client.receipts.all() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/receipts' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/receipts' + ) def test_all_calls_correct_url_with_params(): @@ -25,11 +27,15 @@ def test_all_calls_correct_url_with_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.receipts.all(query_param1='value1', query_param2='value2') + client.receipts.all({ + 'query_param1': 'value1', + 'query_param2': 'value2', + }) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/receipts?') - assert 'query_param1=value1' in responses.calls[0].request.url - assert 'query_param2=value2' in responses.calls[0].request.url + url = responses.calls[0].request.url + assert url.startswith('http://127.0.0.1:4002/api/receipts?') + assert 'query_param1=value1' in url + assert 'query_param2=value2' in url def test_get_calls_correct_url(): @@ -44,4 +50,6 @@ def test_get_calls_correct_url(): client = ArkClient('http://127.0.0.1:4002/api') client.receipts.get(transaction_hash) assert len(responses.calls) == 1 - assert responses.calls[0].request.url == f'http://127.0.0.1:4002/api/receipts/{transaction_hash}' + assert responses.calls[0].request.url == ( + f'http://127.0.0.1:4002/api/receipts/{transaction_hash}' + ) diff --git a/tests/api/test_rounds.py b/tests/api/test_rounds.py index eea73e2..1edbd99 100644 --- a/tests/api/test_rounds.py +++ b/tests/api/test_rounds.py @@ -13,7 +13,9 @@ def test_all_calls_correct_url(): client = ArkClient('http://127.0.0.1:4002/api') client.rounds.all() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/rounds' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/rounds' + ) def test_all_calls_correct_url_with_params(): @@ -25,11 +27,15 @@ def test_all_calls_correct_url_with_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.rounds.all(query_param1='value1', query_param2='value2') + client.rounds.all({ + 'query_param1': 'value1', + 'query_param2': 'value2', + }) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/rounds?') - assert 'query_param1=value1' in responses.calls[0].request.url - assert 'query_param2=value2' in responses.calls[0].request.url + url = responses.calls[0].request.url + assert url.startswith('http://127.0.0.1:4002/api/rounds?') + assert 'query_param1=value1' in url + assert 'query_param2=value2' in url def test_show_calls_correct_url(): @@ -44,7 +50,9 @@ def test_show_calls_correct_url(): client = ArkClient('http://127.0.0.1:4002/api') client.rounds.show(round_id) assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/rounds/12345' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/rounds/12345' + ) def test_validators_calls_correct_url(): @@ -60,4 +68,6 @@ def test_validators_calls_correct_url(): client.rounds.validators(round_id) assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/rounds/12345/validators' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/rounds/12345/validators' + ) diff --git a/tests/api/test_tokens.py b/tests/api/test_tokens.py index 3fb62a0..3aa6ec5 100644 --- a/tests/api/test_tokens.py +++ b/tests/api/test_tokens.py @@ -3,7 +3,7 @@ from client import ArkClient -def test_all_calls_correct_url_with_default_params(): +def test_all_calls_correct_url(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/tokens', @@ -14,10 +14,12 @@ def test_all_calls_correct_url_with_default_params(): client = ArkClient('http://127.0.0.1:4002/api') client.tokens.all() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/tokens?limit=100' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/tokens' + ) -def test_all_calls_correct_url_with_passed_in_params(): +def test_all_calls_correct_url_with_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/tokens', @@ -26,11 +28,12 @@ def test_all_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.tokens.all(page=5, limit=69) + client.tokens.all({'page': 5, 'limit': 69}) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/tokens?') - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url + url = responses.calls[0].request.url + assert url.startswith('http://127.0.0.1:4002/api/tokens?') + assert 'page=5' in url + assert 'limit=69' in url def test_get_calls_correct_url(): @@ -50,7 +53,7 @@ def test_get_calls_correct_url(): ) -def test_holders_calls_correct_url_with_default_params(): +def test_holders_calls_correct_url(): address = '0x1234567890abcdef' responses.add( responses.GET, @@ -63,11 +66,11 @@ def test_holders_calls_correct_url_with_default_params(): client.tokens.holders(address) assert len(responses.calls) == 1 assert responses.calls[0].request.url == ( - 'http://127.0.0.1:4002/api/tokens/0x1234567890abcdef/holders?limit=100' + 'http://127.0.0.1:4002/api/tokens/0x1234567890abcdef/holders' ) -def test_holders_calls_correct_url_with_passed_in_params(): +def test_holders_calls_correct_url_with_params(): address = '0x1234567890abcdef' responses.add( responses.GET, @@ -77,16 +80,17 @@ def test_holders_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.tokens.holders(address, page=3, limit=50) + client.tokens.holders(address, {'page': 3, 'limit': 50}) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith( + url = responses.calls[0].request.url + assert url.startswith( 'http://127.0.0.1:4002/api/tokens/0x1234567890abcdef/holders?' ) - assert 'page=3' in responses.calls[0].request.url - assert 'limit=50' in responses.calls[0].request.url + assert 'page=3' in url + assert 'limit=50' in url -def test_transfers_by_token_calls_correct_url_with_default_params(): +def test_transfers_by_token_calls_correct_url(): address = '0x1234567890abcdef' responses.add( responses.GET, @@ -99,11 +103,11 @@ def test_transfers_by_token_calls_correct_url_with_default_params(): client.tokens.transfers_by_token(address) assert len(responses.calls) == 1 assert responses.calls[0].request.url == ( - 'http://127.0.0.1:4002/api/tokens/0x1234567890abcdef/transfers?limit=100' + 'http://127.0.0.1:4002/api/tokens/0x1234567890abcdef/transfers' ) -def test_transfers_by_token_calls_correct_url_with_passed_in_params(): +def test_transfers_by_token_calls_correct_url_with_params(): address = '0x1234567890abcdef' responses.add( responses.GET, @@ -113,16 +117,17 @@ def test_transfers_by_token_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.tokens.transfers_by_token(address, page=2, limit=25) + client.tokens.transfers_by_token(address, {'page': 2, 'limit': 25}) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith( + url = responses.calls[0].request.url + assert url.startswith( 'http://127.0.0.1:4002/api/tokens/0x1234567890abcdef/transfers?' ) - assert 'page=2' in responses.calls[0].request.url - assert 'limit=25' in responses.calls[0].request.url + assert 'page=2' in url + assert 'limit=25' in url -def test_transfers_calls_correct_url_with_default_params(): +def test_transfers_calls_correct_url(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/tokens/transfers', @@ -134,11 +139,11 @@ def test_transfers_calls_correct_url_with_default_params(): client.tokens.transfers() assert len(responses.calls) == 1 assert responses.calls[0].request.url == ( - 'http://127.0.0.1:4002/api/tokens/transfers?limit=100' + 'http://127.0.0.1:4002/api/tokens/transfers' ) -def test_transfers_calls_correct_url_with_passed_in_params(): +def test_transfers_calls_correct_url_with_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/tokens/transfers', @@ -147,10 +152,11 @@ def test_transfers_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.tokens.transfers(page=1, limit=10) + client.tokens.transfers({'page': 1, 'limit': 10}) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith( + url = responses.calls[0].request.url + assert url.startswith( 'http://127.0.0.1:4002/api/tokens/transfers?' ) - assert 'page=1' in responses.calls[0].request.url - assert 'limit=10' in responses.calls[0].request.url + assert 'page=1' in url + assert 'limit=10' in url diff --git a/tests/api/test_transactions.py b/tests/api/test_transactions.py index 4ffcffb..25cc196 100644 --- a/tests/api/test_transactions.py +++ b/tests/api/test_transactions.py @@ -5,7 +5,7 @@ from client import ArkClient -def test_all_calls_correct_url_with_default_params(): +def test_all_calls_correct_url(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/transactions', @@ -16,10 +16,12 @@ def test_all_calls_correct_url_with_default_params(): client = ArkClient('http://127.0.0.1:4002/api') client.transactions.all() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/transactions?limit=100' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/transactions' + ) -def test_all_calls_correct_url_with_passed_in_params(): +def test_all_calls_correct_url_with_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/transactions', @@ -28,28 +30,19 @@ def test_all_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.transactions.all(page=5, limit=69) + 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/api/transactions?') - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url - - -def test_all_calls_correct_url_with_additional_params(): - responses.add( - responses.GET, - 'http://127.0.0.1:4002/api/transactions', - json={'success': True}, - status=200 + url = responses.calls[0].request.url + assert url.startswith( + 'http://127.0.0.1:4002/api/transactions?' ) - - client = ArkClient('http://127.0.0.1:4002/api') - 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/api/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 + assert 'page=5' in url + assert 'limit=69' in url + assert 'orderBy=timestamp.epoch' in url def test_create_calls_correct_url_with_data(): @@ -63,7 +56,9 @@ def test_create_calls_correct_url_with_data(): client = ArkClient('http://127.0.0.1:4002/tx/api') client.transactions.create([{'random': 'data'}]) assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/tx/api/transactions' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/tx/api/transactions' + ) assert json.loads(responses.calls[0].request.body.decode()) == { 'transactions': [{'random': 'data'}] } @@ -73,7 +68,9 @@ def test_get_calls_correct_url(): transaction_id = '12345' responses.add( responses.GET, - 'http://127.0.0.1:4002/api/transactions/{}'.format(transaction_id), + 'http://127.0.0.1:4002/api/transactions/{}'.format( + transaction_id + ), json={'success': True}, status=200 ) @@ -82,10 +79,12 @@ def test_get_calls_correct_url(): client.transactions.get(transaction_id) assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/transactions/12345' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/transactions/12345' + ) -def test_all_unconfirmed_calls_correct_url_with_default_params(): +def test_all_unconfirmed_calls_correct_url(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/transactions/unconfirmed', @@ -97,11 +96,11 @@ def test_all_unconfirmed_calls_correct_url_with_default_params(): client.transactions.all_unconfirmed() assert len(responses.calls) == 1 assert responses.calls[0].request.url == ( - 'http://127.0.0.1:4002/api/transactions/unconfirmed?limit=100' + 'http://127.0.0.1:4002/api/transactions/unconfirmed' ) -def test_all_unconfirmed_calls_correct_url_with_passed_in_params(): +def test_all_unconfirmed_calls_correct_url_with_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/transactions/unconfirmed', @@ -110,46 +109,39 @@ def test_all_unconfirmed_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.transactions.all_unconfirmed(offset=5, limit=69) + client.transactions.all_unconfirmed({ + 'page': 5, + 'limit': 69, + 'orderBy': 'timestamp.epoch', + }) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith( + url = responses.calls[0].request.url + assert url.startswith( 'http://127.0.0.1:4002/api/transactions/unconfirmed?' ) - assert 'offset=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url - - -def test_all_unconfirmed_calls_correct_url_with_additional_params(): - responses.add( - responses.GET, - 'http://127.0.0.1:4002/api/transactions/unconfirmed', - json={'success': True}, - status=200 - ) - - client = ArkClient('http://127.0.0.1:4002/api') - 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/api/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 + assert 'page=5' in url + assert 'limit=69' in url + assert 'orderBy=timestamp.epoch' in url def test_get_unconfirmed_calls_correct_url(): transaction_id = '12345' responses.add( - responses.GET, - 'http://127.0.0.1:4002/api/transactions/unconfirmed/{}'.format(transaction_id), - json={'success': True}, - status=200 + responses.GET, + 'http://127.0.0.1:4002/api/transactions/unconfirmed/{}'.format( + transaction_id + ), + json={'success': True}, + status=200 ) client = ArkClient('http://127.0.0.1:4002/api') client.transactions.get_unconfirmed(transaction_id) assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/transactions/unconfirmed/12345' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/transactions/unconfirmed/12345' + ) def test_configuration_calls_correct_url(): @@ -167,4 +159,6 @@ def test_configuration_calls_correct_url(): }) client.transactions.configuration() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/tx/api/configuration' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/tx/api/configuration' + ) diff --git a/tests/api/test_validators.py b/tests/api/test_validators.py index e400b2d..df745dd 100644 --- a/tests/api/test_validators.py +++ b/tests/api/test_validators.py @@ -1,11 +1,9 @@ -import json - import responses from client import ArkClient -def test_all_calls_correct_url_with_default_params(): +def test_all_calls_correct_url(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/validators', @@ -16,10 +14,12 @@ def test_all_calls_correct_url_with_default_params(): client = ArkClient('http://127.0.0.1:4002/api') client.validators.all() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/validators?limit=100' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/validators' + ) -def test_all_calls_correct_url_with_passed_in_params(): +def test_all_calls_correct_url_with_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/validators', @@ -28,28 +28,19 @@ def test_all_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.validators.all(page=5, limit=69) + client.validators.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/api/validators?') - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url - - -def test_all_calls_correct_url_with_additional_params(): - responses.add( - responses.GET, - 'http://127.0.0.1:4002/api/validators', - json={'success': True}, - status=200 + url = responses.calls[0].request.url + assert url.startswith( + 'http://127.0.0.1:4002/api/validators?' ) - - client = ArkClient('http://127.0.0.1:4002/api') - client.validators.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/api/validators?') - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url - assert 'orderBy=username' in responses.calls[0].request.url + assert 'page=5' in url + assert 'limit=69' in url + assert 'orderBy=username' in url def test_get_calls_correct_url(): @@ -65,40 +56,58 @@ def test_get_calls_correct_url(): client.validators.get(validator_id) assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/validators/12345' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/validators/12345' + ) def test_blocks_calls_correct_url(): validator_id = '12345' responses.add( responses.GET, - 'http://127.0.0.1:4002/api/validators/{}/blocks'.format(validator_id), + 'http://127.0.0.1:4002/api/validators/{}/blocks'.format( + validator_id + ), json={'success': True}, status=200 ) client = ArkClient('http://127.0.0.1:4002/api') - client.validators.blocks(validator_id, limit=100, orderBy='timestamp:desc') + client.validators.blocks(validator_id, { + 'limit': 100, + 'orderBy': 'timestamp:desc', + }) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/validators/12345/blocks?') - assert 'limit=100' in responses.calls[0].request.url - assert 'orderBy=timestamp%3Adesc' in responses.calls[0].request.url + url = responses.calls[0].request.url + assert url.startswith( + 'http://127.0.0.1:4002/api/validators/12345/blocks?' + ) + assert 'limit=100' in url + assert 'orderBy=timestamp%3Adesc' in url def test_voters_calls_correct_url(): validator_id = '12345' responses.add( responses.GET, - 'http://127.0.0.1:4002/api/validators/{}/voters'.format(validator_id), + 'http://127.0.0.1:4002/api/validators/{}/voters'.format( + validator_id + ), json={'success': True}, status=200 ) client = ArkClient('http://127.0.0.1:4002/api') - client.validators.voters(validator_id, limit=100, orderBy='timestamp:desc') + client.validators.voters(validator_id, { + 'limit': 100, + 'orderBy': 'timestamp:desc', + }) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/validators/12345/voters?') - assert 'limit=100' in responses.calls[0].request.url - assert 'orderBy=timestamp%3Adesc' in responses.calls[0].request.url + url = responses.calls[0].request.url + assert url.startswith( + 'http://127.0.0.1:4002/api/validators/12345/voters?' + ) + assert 'limit=100' in url + assert 'orderBy=timestamp%3Adesc' in url diff --git a/tests/api/test_votes.py b/tests/api/test_votes.py index ff9a614..a924ae3 100644 --- a/tests/api/test_votes.py +++ b/tests/api/test_votes.py @@ -3,7 +3,7 @@ from client import ArkClient -def test_all_calls_correct_url_with_default_params(): +def test_all_calls_correct_url(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/votes', @@ -14,10 +14,12 @@ def test_all_calls_correct_url_with_default_params(): client = ArkClient('http://127.0.0.1:4002/api') client.votes.all() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/votes?limit=100' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/votes' + ) -def test_all_calls_correct_url_with_passed_in_params(): +def test_all_calls_correct_url_with_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/votes', @@ -26,11 +28,12 @@ def test_all_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.votes.all(page=5, limit=69) + client.votes.all({'page': 5, 'limit': 69}) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/votes?') - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url + url = responses.calls[0].request.url + assert url.startswith('http://127.0.0.1:4002/api/votes?') + assert 'page=5' in url + assert 'limit=69' in url def test_get_calls_correct_url(): @@ -46,4 +49,6 @@ def test_get_calls_correct_url(): client.votes.get(vote_id) assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/votes/12345' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/votes/12345' + ) diff --git a/tests/api/test_wallets.py b/tests/api/test_wallets.py index f3e5b2e..c9b0ed2 100644 --- a/tests/api/test_wallets.py +++ b/tests/api/test_wallets.py @@ -1,11 +1,9 @@ -import json - import responses from client import ArkClient -def test_all_calls_correct_url_with_default_params(): +def test_all_calls_correct_url(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/wallets', @@ -16,10 +14,12 @@ def test_all_calls_correct_url_with_default_params(): client = ArkClient('http://127.0.0.1:4002/api') client.wallets.all() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/wallets?limit=100' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/wallets' + ) -def test_all_calls_correct_url_with_passed_in_params(): +def test_all_calls_correct_url_with_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/wallets', @@ -28,14 +28,15 @@ def test_all_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.wallets.all(page=5, limit=69) + client.wallets.all({'page': 5, 'limit': 69}) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/wallets?') - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url + url = responses.calls[0].request.url + assert url.startswith('http://127.0.0.1:4002/api/wallets?') + assert 'page=5' in url + assert 'limit=69' in url -def test_top_calls_correct_url_with_default_params(): +def test_top_calls_correct_url(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/wallets/top', @@ -46,10 +47,12 @@ def test_top_calls_correct_url_with_default_params(): client = ArkClient('http://127.0.0.1:4002/api') client.wallets.top() assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/wallets/top?limit=100' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/wallets/top' + ) -def test_top_calls_correct_url_with_passed_in_params(): +def test_top_calls_correct_url_with_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/wallets/top', @@ -58,11 +61,12 @@ def test_top_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.wallets.top(page=5, limit=69) + client.wallets.top({'page': 5, 'limit': 69}) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/wallets/top?') - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url + url = responses.calls[0].request.url + assert url.startswith('http://127.0.0.1:4002/api/wallets/top?') + assert 'page=5' in url + assert 'limit=69' in url def test_get_calls_correct_url(): @@ -78,13 +82,18 @@ def test_get_calls_correct_url(): client.wallets.get(wallet_id) assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/wallets/12345' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/wallets/12345' + ) + -def test_transactions_calls_correct_url_with_default_params(): +def test_transactions_calls_correct_url(): wallet_id = '12345' responses.add( responses.GET, - 'http://127.0.0.1:4002/api/wallets/{}/transactions'.format(wallet_id), + 'http://127.0.0.1:4002/api/wallets/{}/transactions'.format( + wallet_id + ), json={'success': True}, status=200 ) @@ -93,52 +102,44 @@ def test_transactions_calls_correct_url_with_default_params(): client.wallets.transactions(wallet_id) assert len(responses.calls) == 1 assert responses.calls[0].request.url == ( - 'http://127.0.0.1:4002/api/wallets/12345/transactions?limit=100' + 'http://127.0.0.1:4002/api/wallets/12345/transactions' ) -def test_transactions_calls_correct_url_with_additional_params(): - wallet_id = '12345' - responses.add( - responses.GET, - 'http://127.0.0.1:4002/api/wallets/{}/transactions'.format(wallet_id), - json={'success': True}, - status=200 - ) - - client = ArkClient('http://127.0.0.1:4002/api') - 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/api/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 - - -def test_transactions_calls_correct_url_with_passed_in_params(): +def test_transactions_calls_correct_url_with_params(): wallet_id = '12345' responses.add( responses.GET, - 'http://127.0.0.1:4002/api/wallets/{}/transactions'.format(wallet_id), + 'http://127.0.0.1:4002/api/wallets/{}/transactions'.format( + wallet_id + ), json={'success': True}, status=200 ) client = ArkClient('http://127.0.0.1:4002/api') - client.wallets.transactions(wallet_id, page=5, limit=69) + client.wallets.transactions(wallet_id, { + 'page': 5, + 'limit': 69, + 'orderBy': 'timestamp.epoch', + }) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith( + url = responses.calls[0].request.url + assert url.startswith( 'http://127.0.0.1:4002/api/wallets/12345/transactions?' ) - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url + assert 'page=5' in url + assert 'limit=69' in url + assert 'orderBy=timestamp.epoch' in url -def test_sent_transactions_calls_correct_url_with_default_params(): +def test_sent_transactions_calls_correct_url(): wallet_id = '12345' responses.add( responses.GET, - 'http://127.0.0.1:4002/api/wallets/{}/transactions/sent'.format(wallet_id), + 'http://127.0.0.1:4002/api/wallets/{}/transactions/sent'.format( + wallet_id + ), json={'success': True}, status=200 ) @@ -147,34 +148,41 @@ def test_sent_transactions_calls_correct_url_with_default_params(): client.wallets.sent_transactions(wallet_id) assert len(responses.calls) == 1 assert responses.calls[0].request.url == ( - 'http://127.0.0.1:4002/api/wallets/12345/transactions/sent?limit=100' + 'http://127.0.0.1:4002/api/wallets/12345/transactions/sent' ) -def test_sent_transactions_calls_correct_url_with_passed_in_params(): +def test_sent_transactions_calls_correct_url_with_params(): wallet_id = '12345' responses.add( responses.GET, - 'http://127.0.0.1:4002/api/wallets/{}/transactions/sent'.format(wallet_id), + 'http://127.0.0.1:4002/api/wallets/{}/transactions/sent'.format( + wallet_id + ), json={'success': True}, status=200 ) client = ArkClient('http://127.0.0.1:4002/api') - client.wallets.sent_transactions(wallet_id, page=5, limit=69) + client.wallets.sent_transactions(wallet_id, { + 'page': 5, + 'limit': 69, + }) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith( + url = responses.calls[0].request.url + assert url.startswith( 'http://127.0.0.1:4002/api/wallets/12345/transactions/sent?' ) - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url + assert 'page=5' in url + assert 'limit=69' in url -def test_received_transactions_calls_correct_url_with_default_params(): +def test_received_transactions_calls_correct_url(): wallet_id = '12345' responses.add( responses.GET, - 'http://127.0.0.1:4002/api/wallets/{}/transactions/received'.format(wallet_id), + 'http://127.0.0.1:4002/api/wallets/{}/transactions/received' + .format(wallet_id), json={'success': True}, status=200 ) @@ -183,30 +191,36 @@ def test_received_transactions_calls_correct_url_with_default_params(): client.wallets.received_transactions(wallet_id) assert len(responses.calls) == 1 assert responses.calls[0].request.url == ( - 'http://127.0.0.1:4002/api/wallets/12345/transactions/received?limit=100' + 'http://127.0.0.1:4002/api/wallets/12345/transactions/received' ) -def test_received_transactions_calls_correct_url_with_passed_in_params(): +def test_received_transactions_calls_correct_url_with_params(): wallet_id = '12345' responses.add( responses.GET, - 'http://127.0.0.1:4002/api/wallets/{}/transactions/received'.format(wallet_id), + 'http://127.0.0.1:4002/api/wallets/{}/transactions/received' + .format(wallet_id), json={'success': True}, status=200 ) client = ArkClient('http://127.0.0.1:4002/api') - client.wallets.received_transactions(wallet_id, page=5, limit=69) + client.wallets.received_transactions(wallet_id, { + 'page': 5, + 'limit': 69, + }) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith( - 'http://127.0.0.1:4002/api/wallets/12345/transactions/received?' + url = responses.calls[0].request.url + assert url.startswith( + 'http://127.0.0.1:4002/api/wallets/12345' + '/transactions/received?' ) - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url + assert 'page=5' in url + assert 'limit=69' in url -def test_votes_calls_correct_url_with_default_params(): +def test_votes_calls_correct_url(): wallet_id = '12345' responses.add( responses.GET, @@ -219,11 +233,11 @@ def test_votes_calls_correct_url_with_default_params(): client.wallets.votes(wallet_id) assert len(responses.calls) == 1 assert responses.calls[0].request.url == ( - 'http://127.0.0.1:4002/api/wallets/12345/votes?limit=100' + 'http://127.0.0.1:4002/api/wallets/12345/votes' ) -def test_votes_calls_correct_url_with_passed_in_params(): +def test_votes_calls_correct_url_with_params(): wallet_id = '12345' responses.add( responses.GET, @@ -233,16 +247,17 @@ def test_votes_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.wallets.votes(wallet_id, page=5, limit=69) + client.wallets.votes(wallet_id, {'page': 5, 'limit': 69}) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith( + url = responses.calls[0].request.url + assert url.startswith( 'http://127.0.0.1:4002/api/wallets/12345/votes?' ) - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url + assert 'page=5' in url + assert 'limit=69' in url -def test_tokens_calls_correct_url_with_default_params(): +def test_tokens_calls_correct_url(): wallet_id = '12345' responses.add( responses.GET, @@ -255,11 +270,11 @@ def test_tokens_calls_correct_url_with_default_params(): client.wallets.tokens(wallet_id) assert len(responses.calls) == 1 assert responses.calls[0].request.url == ( - 'http://127.0.0.1:4002/api/wallets/12345/tokens?limit=100' + 'http://127.0.0.1:4002/api/wallets/12345/tokens' ) -def test_tokens_calls_correct_url_with_passed_in_params(): +def test_tokens_calls_correct_url_with_params(): wallet_id = '12345' responses.add( responses.GET, @@ -269,16 +284,17 @@ def test_tokens_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.wallets.tokens(wallet_id, page=5, limit=69) + client.wallets.tokens(wallet_id, {'page': 5, 'limit': 69}) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith( + url = responses.calls[0].request.url + assert url.startswith( 'http://127.0.0.1:4002/api/wallets/12345/tokens?' ) - assert 'page=5' in responses.calls[0].request.url - assert 'limit=69' in responses.calls[0].request.url + assert 'page=5' in url + assert 'limit=69' in url -def test_tokens_for_calls_correct_url_with_default_params(): +def test_tokens_for_calls_correct_url(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/wallets/tokens', @@ -287,16 +303,18 @@ def test_tokens_for_calls_correct_url_with_default_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.wallets.tokens_for('0xabc,0xdef') + client.wallets.tokens_for({ + 'addresses': '0xabc,0xdef', + }) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith( + url = responses.calls[0].request.url + assert url.startswith( 'http://127.0.0.1:4002/api/wallets/tokens?' ) - assert 'addresses=0xabc%2C0xdef' in responses.calls[0].request.url - assert 'limit=100' in responses.calls[0].request.url + assert 'addresses=0xabc%2C0xdef' in url -def test_tokens_for_calls_correct_url_with_passed_in_params(): +def test_tokens_for_calls_correct_url_with_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/wallets/tokens', @@ -305,10 +323,15 @@ def test_tokens_for_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.wallets.tokens_for('0xabc,0xdef', page=2, limit=50) + client.wallets.tokens_for({ + 'addresses': '0xabc,0xdef', + 'page': 2, + 'limit': 50, + }) assert len(responses.calls) == 1 - assert responses.calls[0].request.url.startswith( + url = responses.calls[0].request.url + assert url.startswith( 'http://127.0.0.1:4002/api/wallets/tokens?' ) - assert 'page=2' in responses.calls[0].request.url - assert 'limit=50' in responses.calls[0].request.url + assert 'page=2' in url + assert 'limit=50' in url