From 91fde9268c51734cf7d31f302695349a2821795d Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Thu, 13 May 2021 15:01:12 +0200 Subject: [PATCH] [enh] #401: Sort imports --- silkaj/auth.py | 7 +++--- silkaj/blockchain_tools.py | 3 ++- silkaj/blocks.py | 8 +++---- silkaj/cert.py | 18 +++++++-------- silkaj/checksum.py | 6 ++--- silkaj/cli.py | 27 +++++++++------------- silkaj/commands.py | 29 ++++++++++------------- silkaj/crypto_tools.py | 2 +- silkaj/license.py | 3 ++- silkaj/membership.py | 17 +++++++------- silkaj/money.py | 15 ++++++------ silkaj/network_tools.py | 7 +++--- silkaj/tools.py | 4 ++-- silkaj/tui.py | 6 +++-- silkaj/tx.py | 25 ++++++++++---------- silkaj/tx_history.py | 19 ++++++++------- silkaj/wot.py | 13 ++++++----- silkaj/wot_tools.py | 3 ++- tests/patched/money.py | 5 ++-- tests/patched/tools.py | 1 + tests/patched/tx.py | 1 + tests/patched/tx_history.py | 2 +- tests/test_auth.py | 10 ++++---- tests/test_checksum.py | 3 +-- tests/test_crypto_tools.py | 1 + tests/test_membership.py | 27 ++++++++-------------- tests/test_money.py | 8 +++---- tests/test_network_tools.py | 1 + tests/test_tui.py | 9 ++++---- tests/test_tx.py | 18 +++++++-------- tests/test_tx_history.py | 11 ++++----- tests/test_unit_cert.py | 1 - tests/test_unit_tx.py | 46 ++++++++++++++++--------------------- tests/test_verify_blocks.py | 16 ++++++------- tests/test_wot.py | 5 ++-- 35 files changed, 178 insertions(+), 199 deletions(-) diff --git a/silkaj/auth.py b/silkaj/auth.py index 74b16f83..3b698978 100644 --- a/silkaj/auth.py +++ b/silkaj/auth.py @@ -16,17 +16,16 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import re -from click import command, option, pass_context, confirm from getpass import getpass from pathlib import Path +from click import command, confirm, option, pass_context from duniterpy.key import SigningKey from duniterpy.key.scrypt_params import ScryptParams -from silkaj.tui import display_pubkey_and_checksum -from silkaj.tools import message_exit from silkaj.constants import PUBKEY_PATTERN - +from silkaj.tools import message_exit +from silkaj.tui import display_pubkey_and_checksum SEED_HEX_PATTERN = "^[0-9a-fA-F]{64}$" PUBSEC_PUBKEY_PATTERN = "pub: ({0})".format(PUBKEY_PATTERN) diff --git a/silkaj/blockchain_tools.py b/silkaj/blockchain_tools.py index df6cc8b9..57d640c8 100644 --- a/silkaj/blockchain_tools.py +++ b/silkaj/blockchain_tools.py @@ -15,9 +15,10 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -from silkaj.network_tools import ClientInstance from duniterpy.api.bma import blockchain +from silkaj.network_tools import ClientInstance + class BlockchainParams(object): __instance = None diff --git a/silkaj/blocks.py b/silkaj/blocks.py index 5d978391..b21bc2e3 100644 --- a/silkaj/blocks.py +++ b/silkaj/blocks.py @@ -17,18 +17,18 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. import logging from asyncio import sleep -from click import command, argument, INT, progressbar -from aiohttp.client_exceptions import ServerDisconnectedError +from aiohttp.client_exceptions import ServerDisconnectedError +from click import INT, argument, command, progressbar from duniterpy.api import bma from duniterpy.api.client import Client from duniterpy.api.errors import DuniterError from duniterpy.documents import Block from duniterpy.key.verifying_key import VerifyingKey -from silkaj.tools import message_exit, coroutine -from silkaj.network_tools import EndPoint from silkaj.constants import BMA_MAX_BLOCKS_CHUNK_SIZE +from silkaj.network_tools import EndPoint +from silkaj.tools import coroutine, message_exit @command( diff --git a/silkaj/cert.py b/silkaj/cert.py index a3f501a0..483f089c 100644 --- a/silkaj/cert.py +++ b/silkaj/cert.py @@ -16,22 +16,22 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import sys + import click +from duniterpy.api import bma +from duniterpy.documents import BlockUID, Certification, Identity, block_uid from pendulum import from_timestamp, now - from tabulate import tabulate -from duniterpy.api import bma -from duniterpy.documents import BlockUID, block_uid, Identity, Certification +from silkaj import tui, wot +from silkaj import wot_tools as wt from silkaj.auth import auth_method -from silkaj.tools import message_exit, coroutine -from silkaj.network_tools import ClientInstance from silkaj.blockchain_tools import BlockchainParams, HeadBlock -from silkaj.license import license_approval -from silkaj import wot, tui -from silkaj.constants import SUCCESS_EXIT_STATUS, DATE, ALL +from silkaj.constants import ALL, DATE, SUCCESS_EXIT_STATUS from silkaj.crypto_tools import is_pubkey_and_check -from silkaj import wot_tools as wt +from silkaj.license import license_approval +from silkaj.network_tools import ClientInstance +from silkaj.tools import coroutine, message_exit @click.command("cert", help="Send certification") diff --git a/silkaj/checksum.py b/silkaj/checksum.py index 19c86dbf..4885e8c2 100644 --- a/silkaj/checksum.py +++ b/silkaj/checksum.py @@ -16,18 +16,18 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import re + import click from silkaj.auth import auth_method, has_auth_method from silkaj.crypto_tools import ( - gen_checksum, - PUBKEY_DELIMITED_PATTERN, PUBKEY_CHECKSUM_PATTERN, + PUBKEY_DELIMITED_PATTERN, + gen_checksum, ) from silkaj.tools import message_exit from silkaj.tui import display_pubkey_and_checksum - MESSAGE = "You should specify a pubkey or an authentication method" diff --git a/silkaj/cli.py b/silkaj/cli.py index fb4c0c86..94f5c027 100644 --- a/silkaj/cli.py +++ b/silkaj/cli.py @@ -16,30 +16,25 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import sys -from click import group, help_option, version_option, option, pass_context -from silkaj.tx import send_transaction -from silkaj.tx_history import transaction_history -from silkaj.money import cmd_amount -from silkaj.cert import send_certification -from silkaj.checksum import checksum_command -from silkaj.commands import ( - currency_info, - difficulties, - argos_info, - list_blocks, -) +from click import group, help_option, option, pass_context, version_option -from silkaj.wot import received_sent_certifications, id_pubkey_correspondence from silkaj.auth import generate_auth_file -from silkaj.license import license_command -from silkaj.membership import send_membership from silkaj.blocks import verify_blocks_signatures +from silkaj.cert import send_certification +from silkaj.checksum import checksum_command +from silkaj.commands import argos_info, currency_info, difficulties, list_blocks from silkaj.constants import ( - SILKAJ_VERSION, G1_DEFAULT_ENDPOINT, G1_TEST_DEFAULT_ENDPOINT, + SILKAJ_VERSION, ) +from silkaj.license import license_command +from silkaj.membership import send_membership +from silkaj.money import cmd_amount +from silkaj.tx import send_transaction +from silkaj.tx_history import transaction_history +from silkaj.wot import id_pubkey_correspondence, received_sent_certifications @group() diff --git a/silkaj/commands.py b/silkaj/commands.py index 1508f3c4..5ddfda68 100644 --- a/silkaj/commands.py +++ b/silkaj/commands.py @@ -15,29 +15,24 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -import aiohttp -import jsonschema -from pendulum import from_timestamp -from click import command, option, argument, IntRange -from os import system +from asyncio import sleep from collections import OrderedDict -from tabulate import tabulate from operator import itemgetter -from asyncio import sleep -from _socket import gaierror +from os import system +import aiohttp +import jsonschema +from _socket import gaierror +from click import IntRange, argument, command, option from duniterpy.api import bma +from pendulum import from_timestamp +from tabulate import tabulate -from silkaj.tools import coroutine -from silkaj.wot_tools import identity_of -from silkaj.network_tools import ( - best_endpoint_address, - EndPoint, - ClientInstance, -) from silkaj.blockchain_tools import HeadBlock -from silkaj.tools import CurrencySymbol -from silkaj.constants import ASYNC_SLEEP, ALL, HOUR +from silkaj.constants import ALL, ASYNC_SLEEP, HOUR +from silkaj.network_tools import ClientInstance, EndPoint, best_endpoint_address +from silkaj.tools import CurrencySymbol, coroutine +from silkaj.wot_tools import identity_of @command("info", help="Display information about currency") diff --git a/silkaj/crypto_tools.py b/silkaj/crypto_tools.py index 0a03375d..b7e84642 100644 --- a/silkaj/crypto_tools.py +++ b/silkaj/crypto_tools.py @@ -15,8 +15,8 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -import re import hashlib +import re import base58 diff --git a/silkaj/license.py b/silkaj/license.py index bdd6f891..939a485f 100644 --- a/silkaj/license.py +++ b/silkaj/license.py @@ -16,7 +16,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import webbrowser -from click import command, echo_via_pager, confirm + +from click import command, confirm, echo_via_pager def license_approval(currency): diff --git a/silkaj/membership.py b/silkaj/membership.py index da81a4fa..9a5a3ca2 100644 --- a/silkaj/membership.py +++ b/silkaj/membership.py @@ -15,22 +15,21 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -import sys import logging +import sys -import pendulum import click -from tabulate import tabulate - +import pendulum from duniterpy.api import bma -from duniterpy.documents import BlockUID, block_uid, Membership +from duniterpy.documents import BlockUID, Membership, block_uid +from tabulate import tabulate -from silkaj import auth, wot, tui -from silkaj.tools import coroutine -from silkaj.network_tools import ClientInstance +from silkaj import auth, tui, wot from silkaj.blockchain_tools import BlockchainParams, HeadBlock +from silkaj.constants import DATE, SUCCESS_EXIT_STATUS from silkaj.license import license_approval -from silkaj.constants import SUCCESS_EXIT_STATUS, DATE +from silkaj.network_tools import ClientInstance +from silkaj.tools import coroutine @click.command( diff --git a/silkaj/money.py b/silkaj/money.py index a4596771..33aed211 100644 --- a/silkaj/money.py +++ b/silkaj/money.py @@ -15,24 +15,23 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -from click import command, argument, pass_context, echo +from click import argument, command, echo, pass_context +from duniterpy.api.bma import blockchain, tx +from duniterpy.documents.transaction import InputSource from tabulate import tabulate from silkaj import wot_tools as wt -from silkaj.network_tools import ClientInstance -from silkaj.blockchain_tools import HeadBlock -from silkaj.tools import CurrencySymbol, message_exit, coroutine from silkaj.auth import auth_method, has_auth_method +from silkaj.blockchain_tools import HeadBlock from silkaj.crypto_tools import ( - is_pubkey_and_check, check_pubkey_format, + is_pubkey_and_check, validate_checksum, ) +from silkaj.network_tools import ClientInstance +from silkaj.tools import CurrencySymbol, coroutine, message_exit from silkaj.tui import display_amount, display_pubkey_and_checksum -from duniterpy.api.bma import tx, blockchain -from duniterpy.documents.transaction import InputSource - @command("balance", help="Get wallet balance") @argument("pubkeys", nargs=-1) diff --git a/silkaj/network_tools.py b/silkaj/network_tools.py index e3687547..3e67b8f7 100644 --- a/silkaj/network_tools.py +++ b/silkaj/network_tools.py @@ -15,18 +15,19 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ +import logging import re import socket -import logging from sys import exit, stderr + from duniterpy.api.client import Client from duniterpy.constants import IPV4_REGEX, IPV6_REGEX from silkaj.constants import ( - G1_DEFAULT_ENDPOINT, - G1_TEST_DEFAULT_ENDPOINT, CONNECTION_TIMEOUT, FAILURE_EXIT_STATUS, + G1_DEFAULT_ENDPOINT, + G1_TEST_DEFAULT_ENDPOINT, ) diff --git a/silkaj/tools.py b/silkaj/tools.py index 53d14be9..b4a10af9 100644 --- a/silkaj/tools.py +++ b/silkaj/tools.py @@ -15,12 +15,12 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -from sys import exit from asyncio import get_event_loop from functools import update_wrapper +from sys import exit -from silkaj.constants import G1_SYMBOL, GTEST_SYMBOL, FAILURE_EXIT_STATUS from silkaj.blockchain_tools import BlockchainParams +from silkaj.constants import FAILURE_EXIT_STATUS, G1_SYMBOL, GTEST_SYMBOL class CurrencySymbol(object): diff --git a/silkaj/tui.py b/silkaj/tui.py index 87463bd2..b61e390f 100644 --- a/silkaj/tui.py +++ b/silkaj/tui.py @@ -16,11 +16,13 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import sys -import click from datetime import datetime -from silkaj import network_tools, constants, wot_tools +import click + +from silkaj import constants from silkaj import crypto_tools as ct +from silkaj import network_tools, wot_tools def display_amount(tx, message, amount, ud_value, currency_symbol): diff --git a/silkaj/tx.py b/silkaj/tx.py index 1dae94a2..2e6fea41 100644 --- a/silkaj/tx.py +++ b/silkaj/tx.py @@ -15,31 +15,30 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -from re import compile, search import math from asyncio import sleep -from tabulate import tabulate +from re import compile, search + import click +from duniterpy.api.bma.tx import process +from duniterpy.documents import BlockUID, Transaction +from duniterpy.documents.transaction import OutputSource, SIGParameter, Unlock +from tabulate import tabulate +from silkaj import auth +from silkaj import blockchain_tools as bt from silkaj import cli_tools -from silkaj import network_tools as nt from silkaj import crypto_tools as ct -from silkaj import blockchain_tools as bt -from silkaj import tools -from silkaj import auth from silkaj import money -from silkaj import tui +from silkaj import network_tools as nt +from silkaj import tools, tui from silkaj.constants import ( + ASYNC_SLEEP, + CENT_MULT_TO_UNIT, MINIMAL_ABSOLUTE_TX_AMOUNT, MINIMAL_RELATIVE_TX_AMOUNT, - CENT_MULT_TO_UNIT, - ASYNC_SLEEP, ) -from duniterpy.api.bma.tx import process -from duniterpy.documents import BlockUID, Transaction -from duniterpy.documents.transaction import OutputSource, Unlock, SIGParameter - MAX_COMMENT_LENGTH = 255 diff --git a/silkaj/tx_history.py b/silkaj/tx_history.py index 1b4a90ed..c7de2ce4 100644 --- a/silkaj/tx_history.py +++ b/silkaj/tx_history.py @@ -15,23 +15,22 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -from pendulum import from_timestamp, now -from click import command, argument, option, echo_via_pager, get_terminal_size -from texttable import Texttable -from operator import itemgetter, neg, eq, ne +from operator import eq, itemgetter, ne, neg +from click import argument, command, echo_via_pager, get_terminal_size, option from duniterpy.api.bma.tx import history from duniterpy.documents.transaction import Transaction +from pendulum import from_timestamp, now +from texttable import Texttable +from silkaj import wot from silkaj import wot_tools as wt +from silkaj.constants import ALL, ALL_DIGITAL +from silkaj.crypto_tools import check_pubkey_format, validate_checksum +from silkaj.money import UDValue, amount_in_current_base, get_amount_from_pubkey from silkaj.network_tools import ClientInstance -from silkaj.tools import coroutine +from silkaj.tools import CurrencySymbol, coroutine from silkaj.tui import display_pubkey_and_checksum -from silkaj.crypto_tools import validate_checksum, check_pubkey_format -from silkaj import wot -from silkaj.money import get_amount_from_pubkey, amount_in_current_base, UDValue -from silkaj.tools import CurrencySymbol -from silkaj.constants import ALL, ALL_DIGITAL @command("history", help="Display transaction history") diff --git a/silkaj/wot.py b/silkaj/wot.py index fd7610d9..9d8cf096 100644 --- a/silkaj/wot.py +++ b/silkaj/wot.py @@ -15,20 +15,21 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ +from collections import OrderedDict + import click +from duniterpy.api.bma import blockchain, wot +from duniterpy.api.errors import DuniterError from pendulum import from_timestamp, now from tabulate import tabulate -from collections import OrderedDict -from duniterpy.api.bma import wot, blockchain -from duniterpy.api.errors import DuniterError from silkaj import wot_tools as wt -from silkaj.network_tools import ClientInstance +from silkaj.blockchain_tools import BlockchainParams +from silkaj.constants import DATE from silkaj.crypto_tools import is_pubkey_and_check +from silkaj.network_tools import ClientInstance from silkaj.tools import coroutine from silkaj.tui import display_pubkey_and_checksum -from silkaj.blockchain_tools import BlockchainParams -from silkaj.constants import DATE def get_sent_certifications(signed, time_first_block, params): diff --git a/silkaj/wot_tools.py b/silkaj/wot_tools.py index 829b105f..06176575 100644 --- a/silkaj/wot_tools.py +++ b/silkaj/wot_tools.py @@ -16,12 +16,13 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ from asyncio import sleep + from duniterpy.api.bma import wot from duniterpy.api.errors import DuniterError +from silkaj.constants import ASYNC_SLEEP from silkaj.network_tools import ClientInstance from silkaj.tools import message_exit -from silkaj.constants import ASYNC_SLEEP async def identity_of(pubkey_uid): diff --git a/tests/patched/money.py b/tests/patched/money.py index ff82f0ec..5bdc1f13 100644 --- a/tests/patched/money.py +++ b/tests/patched/money.py @@ -17,11 +17,12 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. # This file contains patched functions for testing purposes. +from duniterpy.documents.transaction import InputSource + +from patched.test_constants import mock_ud_value from silkaj.constants import G1_SYMBOL from silkaj.money import amount_in_current_base from silkaj.tx import MAX_INPUTS_PER_TX -from duniterpy.documents.transaction import InputSource -from patched.test_constants import mock_ud_value async def patched_ud_value(self): diff --git a/tests/patched/tools.py b/tests/patched/tools.py index 4128f88a..2b6bf706 100644 --- a/tests/patched/tools.py +++ b/tests/patched/tools.py @@ -17,6 +17,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. from silkaj.constants import G1_SYMBOL + # mock CurrencySymbol().symbol async def patched_currency_symbol(self): return G1_SYMBOL diff --git a/tests/patched/tx.py b/tests/patched/tx.py index 631c2ff8..949aed89 100644 --- a/tests/patched/tx.py +++ b/tests/patched/tx.py @@ -16,6 +16,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ from duniterpy.key import SigningKey + from silkaj.tools import message_exit diff --git a/tests/patched/tx_history.py b/tests/patched/tx_history.py index bc325de1..ee475904 100644 --- a/tests/patched/tx_history.py +++ b/tests/patched/tx_history.py @@ -17,8 +17,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. from duniterpy.documents.transaction import Transaction -from patched.wot import pubkey_list from patched.blockchain_tools import currency +from patched.wot import pubkey_list fake_received_tx_hist = [ { diff --git a/tests/test_auth.py b/tests/test_auth.py index a238ee6d..39b52412 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -1,14 +1,14 @@ -import pytest import click - -from silkaj import auth +import pytest from patched.auth import ( - patched_auth_by_seed, - patched_auth_by_wif, patched_auth_by_auth_file, patched_auth_by_scrypt, + patched_auth_by_seed, + patched_auth_by_wif, ) +from silkaj import auth + # test auth_method @pytest.mark.parametrize( diff --git a/tests/test_checksum.py b/tests/test_checksum.py index 2a38cfd9..decb8359 100644 --- a/tests/test_checksum.py +++ b/tests/test_checksum.py @@ -18,9 +18,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. import pytest from click.testing import CliRunner -from silkaj.cli import cli from silkaj.checksum import MESSAGE - +from silkaj.cli import cli pubkey = "3rp7ahDGeXqffBQTnENiXEFXYS7BRjYmS33NbgfCuDc8" checksum = "DFQ" diff --git a/tests/test_crypto_tools.py b/tests/test_crypto_tools.py index 10c24721..e9eaa13a 100644 --- a/tests/test_crypto_tools.py +++ b/tests/test_crypto_tools.py @@ -19,6 +19,7 @@ import pytest from silkaj import crypto_tools + # test gen_checksum @pytest.mark.parametrize( "pubkey, checksum", diff --git a/tests/test_membership.py b/tests/test_membership.py index c763ffb7..08250e71 100644 --- a/tests/test_membership.py +++ b/tests/test_membership.py @@ -17,38 +17,31 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. import sys from unittest.mock import Mock -import pytest -from click.testing import CliRunner -from tabulate import tabulate import pendulum - -from duniterpy.documents import Membership, block_uid +import pytest +from click.testing import CliRunner from duniterpy.api import bma +from duniterpy.documents import Membership, block_uid from duniterpy.key import SigningKey +from tabulate import tabulate from patched.blockchain_tools import ( currency, - patched_params, + fake_block_uid, patched_block, patched_head_block, - fake_block_uid, + patched_params, ) from patched.wot import ( - patched_wot_requirements_one_pending, patched_wot_requirements_no_pending, + patched_wot_requirements_one_pending, ) - -from silkaj import auth, wot +from silkaj import auth, membership, wot +from silkaj.blockchain_tools import BlockchainParams, HeadBlock from silkaj.cli import cli +from silkaj.constants import DATE, FAILURE_EXIT_STATUS, SUCCESS_EXIT_STATUS from silkaj.network_tools import ClientInstance -from silkaj import membership -from silkaj.blockchain_tools import BlockchainParams, HeadBlock -from silkaj.constants import ( - SUCCESS_EXIT_STATUS, - FAILURE_EXIT_STATUS, - DATE, -) from silkaj.tui import display_pubkey_and_checksum # AsyncMock available from Python 3.8. asynctest is used for Py < 3.8 diff --git a/tests/test_money.py b/tests/test_money.py index eaaa7467..a179e749 100644 --- a/tests/test_money.py +++ b/tests/test_money.py @@ -15,17 +15,17 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ +import duniterpy.api.bma.tx as bma_tx import pytest from click.testing import CliRunner -import duniterpy.api.bma.tx as bma_tx - -# had to import from wot to prevent loop dependencies -from silkaj.wot import display_pubkey_and_checksum from silkaj.cli import cli from silkaj.constants import FAILURE_EXIT_STATUS from silkaj.money import get_sources +# had to import from wot to prevent loop dependencies +from silkaj.wot import display_pubkey_and_checksum + @pytest.mark.asyncio async def test_get_sources(monkeypatch): diff --git a/tests/test_network_tools.py b/tests/test_network_tools.py index 2f3b9744..127a97d8 100644 --- a/tests/test_network_tools.py +++ b/tests/test_network_tools.py @@ -16,6 +16,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import pytest + from silkaj import network_tools diff --git a/tests/test_tui.py b/tests/test_tui.py index 3fd413d1..6de018c6 100644 --- a/tests/test_tui.py +++ b/tests/test_tui.py @@ -16,12 +16,13 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import pytest -from silkaj.tui import display_pubkey, display_amount, display_pubkey_and_checksum -from silkaj.constants import G1_SYMBOL, SHORT_PUBKEY_SIZE -from silkaj import wot_tools -from patched.wot import patched_is_member from patched.test_constants import mock_ud_value +from patched.wot import patched_is_member +from silkaj import wot_tools +from silkaj.constants import G1_SYMBOL, SHORT_PUBKEY_SIZE +from silkaj.tui import display_amount, display_pubkey, display_pubkey_and_checksum + # display_amount() @pytest.mark.parametrize( diff --git a/tests/test_tx.py b/tests/test_tx.py index c6b1909b..92ab426f 100644 --- a/tests/test_tx.py +++ b/tests/test_tx.py @@ -16,25 +16,25 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import sys + import pytest -from click.testing import CliRunner from click import pass_context +from click.testing import CliRunner -from silkaj import tx, auth, money +from patched.auth import patched_auth_method +from patched.money import patched_get_sources, patched_ud_value +from patched.test_constants import mock_ud_value +from patched.tx import patched_gen_confirmation_table +from silkaj import auth, money, tx from silkaj.cli import cli from silkaj.constants import ( + CENT_MULT_TO_UNIT, + FAILURE_EXIT_STATUS, MINIMAL_ABSOLUTE_TX_AMOUNT, MINIMAL_RELATIVE_TX_AMOUNT, - FAILURE_EXIT_STATUS, - CENT_MULT_TO_UNIT, PUBKEY_MIN_LENGTH, ) -from patched.money import patched_ud_value, patched_get_sources -from patched.test_constants import mock_ud_value -from patched.auth import patched_auth_method -from patched.tx import patched_gen_confirmation_table - # AsyncMock available from Python 3.8. asynctest is used for Py < 3.8 if sys.version_info[1] > 7: from unittest.mock import AsyncMock diff --git a/tests/test_tx_history.py b/tests/test_tx_history.py index ace73404..38f4e7c8 100644 --- a/tests/test_tx_history.py +++ b/tests/test_tx_history.py @@ -16,19 +16,18 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import pytest +from patched.blockchain_tools import currency +from patched.tx_history import patched_get_transactions_history +from patched.wot import patched_identities_from_pubkeys from silkaj import tx_history, wot, wot_tools from silkaj.constants import ( G1_DEFAULT_ENDPOINT, - SHORT_PUBKEY_SIZE, - PUBKEY_MIN_LENGTH, PUBKEY_MAX_LENGTH, + PUBKEY_MIN_LENGTH, + SHORT_PUBKEY_SIZE, ) from silkaj.crypto_tools import CHECKSUM_SIZE -from patched.tx_history import patched_get_transactions_history -from patched.wot import patched_identities_from_pubkeys -from patched.blockchain_tools import currency - SHORT_PUBKEY_LENGTH_WITH_CHECKSUM = ( SHORT_PUBKEY_SIZE + CHECKSUM_SIZE + 2 ) # 2 chars "…:" ==> 8 + 3 + 2 = 13 diff --git a/tests/test_unit_cert.py b/tests/test_unit_cert.py index fa09d368..7b96e03b 100644 --- a/tests/test_unit_cert.py +++ b/tests/test_unit_cert.py @@ -19,7 +19,6 @@ from unittest.mock import patch from silkaj.cert import certification_confirmation - # @patch('builtins.input') # def test_certification_confirmation(mock_input): # id_to_certify = {"pubkey": "pubkeyid to certify"} diff --git a/tests/test_unit_tx.py b/tests/test_unit_tx.py index 62fc092c..a1ac4923 100644 --- a/tests/test_unit_tx.py +++ b/tests/test_unit_tx.py @@ -16,47 +16,41 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import sys -import pytest -from silkaj import ( - tx, - wot, - wot_tools, - money, - tools, - blockchain_tools, - auth, - network_tools, -) -from silkaj.tui import display_pubkey, display_amount -from silkaj.constants import ( - G1_SYMBOL, - CENT_MULT_TO_UNIT, - MINIMAL_ABSOLUTE_TX_AMOUNT, -) -from silkaj.cli import cli - -from click.testing import CliRunner +import pytest from click import pass_context - +from click.testing import CliRunner from duniterpy.documents.transaction import ( InputSource, - Transaction, OutputSource, - Unlock, SIGParameter, + Transaction, + Unlock, ) -from patched.wot import patched_is_member +from patched.auth import patched_auth_method +from patched.blockchain_tools import fake_block_uid, patched_head_block from patched.money import patched_get_sources, patched_ud_value from patched.test_constants import mock_ud_value from patched.tools import patched_currency_symbol -from patched.blockchain_tools import patched_head_block, fake_block_uid -from patched.auth import patched_auth_method from patched.tx import ( patched_gen_confirmation_table, patched_handle_intermediaries_transactions, ) +from patched.wot import patched_is_member +from silkaj import ( + auth, + blockchain_tools, + money, + network_tools, + tools, + tx, + wot, + wot_tools, +) +from silkaj.cli import cli +from silkaj.constants import CENT_MULT_TO_UNIT, G1_SYMBOL, MINIMAL_ABSOLUTE_TX_AMOUNT +from silkaj.tui import display_amount, display_pubkey # AsyncMock available from Python 3.8. asynctest is used for Py < 3.8 if sys.version_info[1] > 7: diff --git a/tests/test_verify_blocks.py b/tests/test_verify_blocks.py index 5a804749..9145cbbe 100644 --- a/tests/test_verify_blocks.py +++ b/tests/test_verify_blocks.py @@ -17,26 +17,24 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. import pytest from click.testing import CliRunner - -from duniterpy.documents import Block -from duniterpy.api.client import Client from duniterpy.api import bma +from duniterpy.api.client import Client +from duniterpy.documents import Block -from silkaj.network_tools import EndPoint from silkaj import cli from silkaj.blocks import ( check_passed_blocks_range, - get_chunk_size, + display_result, get_chunk, + get_chunk_size, verify_block_signature, - display_result, ) from silkaj.constants import ( - SUCCESS_EXIT_STATUS, - FAILURE_EXIT_STATUS, BMA_MAX_BLOCKS_CHUNK_SIZE, + FAILURE_EXIT_STATUS, + SUCCESS_EXIT_STATUS, ) - +from silkaj.network_tools import EndPoint G1_INVALID_BLOCK_SIG = 15144 HEAD_BLOCK = 48000 diff --git a/tests/test_wot.py b/tests/test_wot.py index 3b4299ed..70fca3f3 100644 --- a/tests/test_wot.py +++ b/tests/test_wot.py @@ -15,11 +15,10 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -import pytest import click +import pytest -from silkaj import wot -from silkaj import wot_tools +from silkaj import wot, wot_tools pubkey_titi_tata = "B4RoF48cTxzmsQDB3UjodKdZ2cVymKSKzgiPVRoMeA88" pubkey_toto_tutu = "totoF48cTxzmsQDB3UjodKdZ2cVymKSKzgiPVRoMeA88" -- GitLab