diff --git a/silkaj/blocks.py b/silkaj/blocks.py index 521287e370305dd60f3ad75746a825af67f163dc..a20947ec59e3dc0ce05cfb3294dc059e5c3d8a34 100644 --- a/silkaj/blocks.py +++ b/silkaj/blocks.py @@ -19,7 +19,6 @@ from click import INT, argument, command, progressbar from duniterpy.api import bma from duniterpy.api.errors import DuniterError from duniterpy.documents import Block -from duniterpy.key.verifying_key import VerifyingKey from silkaj.constants import BMA_MAX_BLOCKS_CHUNK_SIZE from silkaj.network_tools import client_instance diff --git a/silkaj/cert.py b/silkaj/cert.py index a3104443a77d65a411c9614e63784ac6672fbf9b..82b5185974a2618f11c0c5d34b0877a5b8a2e794 100644 --- a/silkaj/cert.py +++ b/silkaj/cert.py @@ -25,7 +25,7 @@ from silkaj import tui, wot from silkaj import wot_tools as wt from silkaj.auth import auth_method from silkaj.blockchain_tools import get_blockchain_parameters, get_head_block -from silkaj.constants import ALL, DATE, SUCCESS_EXIT_STATUS +from silkaj.constants import ALL, DATE from silkaj.crypto_tools import is_pubkey_and_check from silkaj.license import license_approval from silkaj.network_tools import client_instance, send_document diff --git a/silkaj/commands.py b/silkaj/commands.py index 72cad11b207ee6dd7c71d6bb194c1d772ba08f25..ab51fe394bb5fcc771058faf8e059f7ec7d1c006 100644 --- a/silkaj/commands.py +++ b/silkaj/commands.py @@ -25,7 +25,7 @@ from tabulate import tabulate from websocket._exceptions import WebSocketConnectionClosedException from silkaj.blockchain_tools import get_head_block -from silkaj.constants import ALL, HOUR +from silkaj.constants import ALL from silkaj.network_tools import client_instance, determine_endpoint from silkaj.tools import get_currency_symbol from silkaj.wot_tools import identity_of diff --git a/silkaj/idty_tools.py b/silkaj/idty_tools.py index 00031c89af01240faeb71295e9e37f1cb3908686..d370a6bdd0f8df2ed489a049883193c018869671 100644 --- a/silkaj/idty_tools.py +++ b/silkaj/idty_tools.py @@ -62,7 +62,7 @@ def check_many_identities(document: Union[Identity, Revocation]): try: results_pubkey = wt.wot_lookup(idty.pubkey) results_uid = wt.wot_lookup(idty.uid) - except urllib.error.HTTPError as e: + except urllib.error.HTTPError: sys.exit( f"{error_no_identical_id}\nuid: {idty.uid}\npubkey: {display_pubkey_and_checksum(idty.pubkey)}" ) @@ -76,7 +76,7 @@ def check_many_identities(document: Union[Identity, Revocation]): match = True break alternate_ids = display_alternate_ids(lookup_ids).draw() - if match == True: + if match: if len(lookup_ids) >= 1: click.echo(f"One matching identity!\nSimilar identities:\n{alternate_ids}") return True diff --git a/silkaj/license.py b/silkaj/license.py index 4110a6179717e54a68d963f73540541015a32581..323e45cbe9e295d8521d11072a77a1a689015b4b 100644 --- a/silkaj/license.py +++ b/silkaj/license.py @@ -14,7 +14,6 @@ # along with Silkaj. If not, see <https://www.gnu.org/licenses/>. from pathlib import Path -from typing import List import click import g1_monetary_license as gml @@ -39,7 +38,8 @@ def license_command() -> None: class G1MonetaryLicense: def __init__(self): - self.licenses_dir_path = gml.__path__.__dict__["_path"][0] # type: ignore # mypy issue #1422 + # mypy issue #1422 + self.licenses_dir_path = gml.__path__.__dict__["_path"][0] # type: ignore self._available_languages() def display_license(self) -> None: @@ -55,7 +55,7 @@ class G1MonetaryLicense: def language_prompt(self) -> str: return click.prompt( - f"In which language would you like to display Ğ1 monetary license?", + "In which language would you like to display Ğ1 monetary license?", type=click.Choice(self.languages_codes), show_choices=True, show_default=True, diff --git a/silkaj/membership.py b/silkaj/membership.py index e7ce01fee80a853f90264a08ab7a75b180eeab78..fab1f72309fe0eec035110f39318ad497130e696 100644 --- a/silkaj/membership.py +++ b/silkaj/membership.py @@ -54,7 +54,6 @@ def send_membership(ctx): license_approval(currency) # Confirmation - client = client_instance() display_confirmation_table(identity_uid, key.pubkey, identity_block_id) if not dry_run and not ctx.obj["DISPLAY_DOCUMENT"]: tui.send_doc_confirmation("membership document for this identity") diff --git a/silkaj/money.py b/silkaj/money.py index 0bb9ca826d418ab1fe821d188a2fe9e18708480f..0f0d3f64eb77f1fa3eda0473883e6404989b581e 100644 --- a/silkaj/money.py +++ b/silkaj/money.py @@ -24,11 +24,7 @@ from tabulate import tabulate from silkaj import wot_tools as wt from silkaj.auth import auth_method, has_auth_method from silkaj.blockchain_tools import get_head_block -from silkaj.crypto_tools import ( - check_pubkey_format, - is_pubkey_and_check, - validate_checksum, -) +from silkaj.crypto_tools import is_pubkey_and_check from silkaj.network_tools import client_instance from silkaj.tools import get_currency_symbol from silkaj.tui import display_amount, display_pubkey_and_checksum diff --git a/silkaj/revocation.py b/silkaj/revocation.py index c191a82f5d1539e3d0a72b735fa597ec1fbfebac..f2785200be324bebdc35c639d8a95f552165220a 100644 --- a/silkaj/revocation.py +++ b/silkaj/revocation.py @@ -14,7 +14,6 @@ # along with Silkaj. If not, see <https://www.gnu.org/licenses/>. -import logging import sys from pathlib import Path @@ -47,7 +46,7 @@ def save(ctx: click.core.Context, file: str): currency = get_currency() key = auth.auth_method() - pubkey_ck = tui.display_pubkey_and_checksum(key.pubkey) + tui.display_pubkey_and_checksum(key.pubkey) id = (wot.choose_identity(key.pubkey))[0] rev_doc = create_revocation_doc(id, key.pubkey, currency) rev_doc.sign(key) @@ -80,7 +79,7 @@ def revoke_now(ctx: click.core.Context): warn_before_dry_run_or_display(ctx) key = auth.auth_method() - pubkey_ck = tui.display_pubkey_and_checksum(key.pubkey) + tui.display_pubkey_and_checksum(key.pubkey) id = (wot.choose_identity(key.pubkey))[0] rev_doc = create_revocation_doc(id, key.pubkey, currency) rev_doc.sign(key) @@ -109,8 +108,6 @@ Optionnaly takes the document filename.", ) @click.pass_context def verify(ctx: click.core.Context, file: str): - currency = get_currency() - rev_doc = verify_document(file) if ctx.obj["DRY_RUN"]: @@ -137,8 +134,6 @@ Optionnaly takes the document filename.", ) @click.pass_context def publish(ctx: click.core.Context, file: str): - currency = get_currency() - warn_before_dry_run_or_display(ctx) rev_doc = verify_document(file) diff --git a/silkaj/tui.py b/silkaj/tui.py index 46e65d820fec1b3918e31ed5480d3a9dbf4e3b20..c35582510d5f9140bb0ca2197f0a6329b2205ad0 100644 --- a/silkaj/tui.py +++ b/silkaj/tui.py @@ -14,7 +14,6 @@ # along with Silkaj. If not, see <https://www.gnu.org/licenses/>. import sys -from datetime import datetime import click diff --git a/silkaj/tx.py b/silkaj/tx.py index a5bc63a340dbb043701ceb88b3cbd900a676ef92..37d5eca30a5f5c8d68030a94f29d206ca7205828 100644 --- a/silkaj/tx.py +++ b/silkaj/tx.py @@ -16,7 +16,6 @@ import math import shlex -import sys from re import compile, search from typing import List diff --git a/silkaj/tx_history.py b/silkaj/tx_history.py index 238478bf0430fdefeb879acac4ea2ecb9f86604c..7dca8b00d8fc6b3c3514747c218423d36421e273 100644 --- a/silkaj/tx_history.py +++ b/silkaj/tx_history.py @@ -22,7 +22,6 @@ 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 @@ -59,7 +58,7 @@ def transaction_history(pubkey, uids, full_pubkey): def generate_header(pubkey, currency_symbol, ud_value): try: idty = wt.identity_of(pubkey) - except: + except Exception: idty = dict([("uid", "")]) balance = get_amount_from_pubkey(pubkey) balance_ud = round(balance[1] / ud_value, 2) diff --git a/silkaj/wot.py b/silkaj/wot.py index b767619b10141de18af8f7e899bd9785d030fce2..0f315cf7a3963512e0d39e516b2c4bffebb69c72 100644 --- a/silkaj/wot.py +++ b/silkaj/wot.py @@ -18,7 +18,6 @@ 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 @@ -27,7 +26,6 @@ from silkaj.blockchain_tools import get_blockchain_parameters from silkaj.constants import DATE from silkaj.crypto_tools import is_pubkey_and_check from silkaj.network_tools import client_instance, exit_on_http_error -from silkaj.tools import message_exit from silkaj.tui import display_pubkey_and_checksum diff --git a/silkaj/wot_tools.py b/silkaj/wot_tools.py index 817e3a6f891ba5ded7a540c319e4eea4c3c2be49..13281dee12e79882d59720853dccc0b2d51ee574 100644 --- a/silkaj/wot_tools.py +++ b/silkaj/wot_tools.py @@ -13,8 +13,6 @@ # 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 - from duniterpy.api.bma import wot from silkaj.network_tools import client_instance @@ -29,7 +27,7 @@ def identity_of(pubkey_uid): client = client_instance() try: return client(wot.identity_of, pubkey_uid) - except ValueError as e: + except ValueError: pass @@ -40,7 +38,7 @@ def is_member(pubkey_uid): """ try: return identity_of(pubkey_uid) - except: + except Exception: return False @@ -67,6 +65,6 @@ def identities_from_pubkeys(pubkeys, uids): for pubkey in uniq_pubkeys: try: identities.append(identity_of(pubkey)) - except Exception as e: + except Exception: pass return identities diff --git a/tests/patched/blockchain_tools.py b/tests/patched/blockchain_tools.py index 6a0b61aaf9f98b3902451dc97cd7ca39c9b29972..c8fcbd7bf5fe693e7568894ebbed3c396ac01cc6 100644 --- a/tests/patched/blockchain_tools.py +++ b/tests/patched/blockchain_tools.py @@ -51,7 +51,7 @@ def patched_block(self, number): return mocked_block -## mock get_head_block() +# mock get_head_block() def patched_get_head_block(): return mocked_block diff --git a/tests/patched/money.py b/tests/patched/money.py index 32d0f815c1e8cfd9511137d20d2561066c015709..7574a195394aae83e9f5775298953cd54b7ce303 100644 --- a/tests/patched/money.py +++ b/tests/patched/money.py @@ -13,29 +13,11 @@ # You should have received a copy of the GNU Affero General Public License # along with Silkaj. If not, see <https://www.gnu.org/licenses/>. -""" -Copyright 2016-2020 Maël Azimi <m.a@moul.re> - -Silkaj is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Silkaj is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -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 @@ -98,7 +80,7 @@ def patched_get_sources(pubkey): a += 1 return balance - listinput, n = list(), 0 + listinput = list() balance = 0 if pubkey == "CtM5RZHopnSRAAoWNgTWrUhDEmspcCAxn6fuCEWDWudp": max_ud = 0 diff --git a/tests/patched/tx.py b/tests/patched/tx.py index 53a535c9e27e748c986975e74757797d1ee5e998..e123ae53e0c2146f74e8a082039b47357c209102 100644 --- a/tests/patched/tx.py +++ b/tests/patched/tx.py @@ -23,7 +23,7 @@ def patched_gen_confirmation_table( pubkey_amount, tx_amounts, outputAddresses, - outputBackChange, + OutputBackChange, comment, ): if not ( @@ -33,7 +33,7 @@ def patched_gen_confirmation_table( and isinstance(tx_amounts, list) and isinstance(outputAddresses, list) and isinstance(comment, str) - and isinstance(outputBackchange, str) + and isinstance(OutputBackChange, str) ) and len(tx_amounts) == len(outputAddresses) and sum(tx_amounts) <= pubkey_amount @@ -49,7 +49,7 @@ def patched_handle_intermediaries_transactions( tx_amounts, outputAddresses, Comment="", - OutputbackChange=None, + OutputBackChange=None, ): if not ( ( @@ -58,7 +58,7 @@ def patched_handle_intermediaries_transactions( and isinstance(tx_amounts, list) and isinstance(outputAddresses, list) and isinstance(Comment, str) - and (isinstance(OutputBackchange, str) or OutputbackChange == None) + and (isinstance(OutputBackChange, str) or not OutputBackChange) ) and len(tx_amounts) == len(outputAddresses) and key.pubkey() == issuers @@ -75,7 +75,7 @@ def patched_generate_and_send_transaction( listinput_and_amount, outputAddresses, Comment, - OutputbackChange, + OutputBackChange, ): if not ( ( @@ -85,7 +85,7 @@ def patched_generate_and_send_transaction( and isinstance(listinput_and_amount, tuple) and isinstance(outputAddresses, list) and isinstance(Comment, str) - and isinstance(OutputBackchange, str) + and isinstance(OutputBackChange, str) ) and len(tx_amounts) == len(outputAddresses) and sum(tx_amounts) <= listinput_and_amount[2] diff --git a/tests/patched/tx_history.py b/tests/patched/tx_history.py index 10e886425aae94c5fc4ae2d08f6f4a7f1c2802b6..b8228c574c68c1879b1f8f0b2e946423eb84ad88 100644 --- a/tests/patched/tx_history.py +++ b/tests/patched/tx_history.py @@ -16,7 +16,6 @@ from duniterpy.documents.transaction import Transaction from patched.blockchain_tools import currency -from patched.wot import pubkey_list fake_received_tx_hist = [ { diff --git a/tests/test_crypto_tools.py b/tests/test_crypto_tools.py index 08b4335b8680c280bc3a94fde384eddca92e4909..8fa5eeba465cf910e1d46074200ab96c801c9ac4 100644 --- a/tests/test_crypto_tools.py +++ b/tests/test_crypto_tools.py @@ -43,11 +43,11 @@ def test_gen_checksum(pubkey, checksum): ) def test_validate_checksum(pubkey, checksum, expected, capsys): pubkey_with_ck = f"{pubkey}:{checksum}" - if expected == None: + if not expected: assert pubkey == crypto_tools.validate_checksum(pubkey_with_ck) else: with pytest.raises(SystemExit) as pytest_exit: - test = crypto_tools.validate_checksum(pubkey_with_ck) + crypto_tools.validate_checksum(pubkey_with_ck) assert capsys.readouterr().out == expected assert pytest_exit.type == SystemExit @@ -65,7 +65,7 @@ def test_validate_checksum(pubkey, checksum, expected, capsys): def test_check_pubkey_format(pubkey, display_error, expected, capsys): if isinstance(expected, str): with pytest.raises(SystemExit) as pytest_exit: - test = crypto_tools.check_pubkey_format(pubkey, display_error) + crypto_tools.check_pubkey_format(pubkey, display_error) assert capsys.readouterr().out == expected assert pytest_exit.type == SystemExit else: @@ -107,6 +107,6 @@ def test_is_pubkey_and_check(uid_pubkey, expected): ) def test_is_pubkey_and_check_errors(uid_pubkey, expected, capsys): with pytest.raises(SystemExit) as pytest_exit: - test = crypto_tools.is_pubkey_and_check(uid_pubkey) + crypto_tools.is_pubkey_and_check(uid_pubkey) assert capsys.readouterr() == expected assert pytest_exit.type == SystemExit diff --git a/tests/test_idty_tools.py b/tests/test_idty_tools.py index 99577c20af0e7e28eea12efe853a6729ef1342cd..e0525e0f0abc80bf67dd3e6adff315898efd8e3c 100644 --- a/tests/test_idty_tools.py +++ b/tests/test_idty_tools.py @@ -19,7 +19,6 @@ import urllib import pendulum import pytest from duniterpy.api import bma -from duniterpy.api.client import DuniterError from duniterpy.documents.block_id import BlockID from duniterpy.documents.identity import Identity @@ -35,7 +34,7 @@ from silkaj import idty_tools from silkaj.constants import ALL, PUBKEY_PATTERN from silkaj.tui import display_pubkey_and_checksum -## used test identities +# used test identities id_moul_test_1 = Identity( currency="g1-test", @@ -366,7 +365,7 @@ def test_check_many_identities( hdrs={}, fp=None, ) - if re.search(PUBKEY_PATTERN, lookup) != None: + if re.search(PUBKEY_PATTERN, lookup): if not lookup_pk: raise http_error return lookup_pk @@ -390,6 +389,6 @@ def test_check_many_identities( result = idty_tools.check_many_identities(idty) assert result == expect_bool display_result = capsys.readouterr().out - if expected != None: + if expected: for expect in expected: assert expect in display_result diff --git a/tests/test_membership.py b/tests/test_membership.py index d413c00b1f64278de61756eba70fb7bb3e7584b0..2643e9dca4e8df42e7e0b30dddb38564f23966ee 100644 --- a/tests/test_membership.py +++ b/tests/test_membership.py @@ -13,7 +13,6 @@ # 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 from unittest.mock import Mock import pendulum @@ -38,7 +37,7 @@ from patched.wot import ( from silkaj import auth, blockchain_tools, membership, wot from silkaj.blockchain_tools import get_blockchain_parameters from silkaj.cli import cli -from silkaj.constants import DATE, FAILURE_EXIT_STATUS, SUCCESS_EXIT_STATUS +from silkaj.constants import DATE from silkaj.network_tools import client_instance from silkaj.tui import display_pubkey_and_checksum @@ -113,7 +112,7 @@ def test_membership_cmd(dry_run, display, confirmation, monkeypatch): if dry_run or display: assert "Type: Membership" in result.output else: - signing_key = patched_auth_method() + # signing_key = patched_auth_method() patched_generate_membership_document.assert_called_once() # membership_block_id is different # patched_generate_membership_document.assert_called_once_with( diff --git a/tests/test_money.py b/tests/test_money.py index 68a93701d8f5b0d11b671c7e4ad9b48d2e1d5912..6a4a9d70a23840bb4eb26fc89000dc4bf84453c7 100644 --- a/tests/test_money.py +++ b/tests/test_money.py @@ -14,7 +14,6 @@ # 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 from silkaj.cli import cli diff --git a/tests/test_network_tools.py b/tests/test_network_tools.py index 7234d219772bd23109afb2ab5fbd5c746b650f19..b09db732c7fbe09b84a163d8357cd2509ae5153b 100644 --- a/tests/test_network_tools.py +++ b/tests/test_network_tools.py @@ -13,15 +13,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 urllib -from unittest.mock import patch +# import urllib +# from unittest.mock import patch import pytest -from duniterpy.api import bma + +# from duniterpy.api import bma from duniterpy.api import endpoint as du_ep from silkaj import constants, network_tools -from silkaj.membership import generate_membership_document + +# from silkaj.membership import generate_membership_document from tests import helpers ipv6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334" diff --git a/tests/test_revocation.py b/tests/test_revocation.py index 223bdb05d7e6c4640de67f062aee2115b38101fe..647ac6535397a1647063beae786f8a8e3e9ab41c 100644 --- a/tests/test_revocation.py +++ b/tests/test_revocation.py @@ -14,8 +14,6 @@ # along with Silkaj. If not, see <https://www.gnu.org/licenses/>. -import os -import sys import urllib from pathlib import Path from unittest.mock import Mock @@ -24,8 +22,6 @@ import click import pytest from click.testing import CliRunner from duniterpy.api import bma -from duniterpy.api.errors import DuniterError -from duniterpy.documents.identity import Identity from duniterpy.documents.revocation import Revocation from patched.auth import patched_auth_method @@ -37,7 +33,7 @@ from silkaj.constants import FAILURE_EXIT_STATUS, SUCCESS_EXIT_STATUS from silkaj.network_tools import client_instance from silkaj.tui import display_pubkey_and_checksum -### useful function ### +# Useful function def display_dry_options(display, dry_run): @@ -49,8 +45,7 @@ def display_dry_options(display, dry_run): return [] -### values ### - +# Values # idty1 REV_DOC = Revocation( @@ -99,7 +94,7 @@ ERROR_CODE = 1005 ERROR_MESSAGE = "Document has unkown fields or wrong line ending format" -## patched functions +# patched functions def patch_get_id_block(node, number): return idty_block @@ -134,7 +129,7 @@ def patched_send_bma_revoke_error(wot_useless, rev_doc_useless): ) -### tests ### +# tests # test cli dry-run @pytest.mark.parametrize( @@ -190,7 +185,7 @@ def test_revocation_cli_dry_run(subcommand, expected_warn, monkeypatch): if expected_warn: assert warning in result.output else: - assert not warning in result.output + assert warning not in result.output # test cli save @@ -433,7 +428,7 @@ def test_revocation_cli_verify( for expect in expected: assert expect in result.output for not_expect in not_expected: - assert not not_expect in result.output + assert not_expect not in result.output # test cli publish @@ -665,7 +660,7 @@ def test_revocation_cli_publish( display, dry_run, doc, lookup, file, user_input, expected, monkeypatch ): def patched_lookup(node, id_pubkey): - if lookup == False: + if not lookup: raise urllib.error.HTTPError( url="this/is/a/test.url", code=404, @@ -777,7 +772,6 @@ def test_revocation_cli_publish_send_errors( file = revocation.REVOCATION_LOCAL_PATH # test publication - client = client_instance() runner = CliRunner() with runner.isolated_filesystem(): with open(file, "w") as f: @@ -911,7 +905,6 @@ def test_revocation_cli_revoke_errors(display, user_input, doc, expected, monkey command = display_dry_options(display, False) command.extend(["revocation", "revoke"]) - client = client_instance() result = CliRunner().invoke(cli, args=command, input=user_input) for expect in expected: @@ -1022,7 +1015,7 @@ def test_verify_document(doc, lookup, capsys, monkeypatch): ) def test_verify_document_missing_id(doc, lookup, capsys, monkeypatch): def patched_lookup(node, id_pubkey): - if lookup == False: + if not lookup: http_error = urllib.error.HTTPError( url="this.is/a/test/url", code=2001, @@ -1043,10 +1036,10 @@ def test_verify_document_missing_id(doc, lookup, capsys, monkeypatch): with open(path, "w") as f: f.write(doc.signed_raw()) with pytest.raises(SystemExit) as pytest_exit: - result = revocation.verify_document(path) + revocation.verify_document(path) assert pytest_exit.type == SystemExit display = capsys.readouterr().out - if lookup == False: + if not lookup: assert "Revocation document does not match any valid identity." in str( pytest_exit.value.code ) @@ -1081,7 +1074,7 @@ def test_verify_document_sign_errors(doc, currency, monkeypatch): elif isinstance(doc, Revocation): f.write(doc.signed_raw()) with pytest.raises(SystemExit) as pytest_exit: - result = revocation.verify_document(path) + revocation.verify_document(path) assert pytest_exit.type == SystemExit if isinstance(doc, str): assert ( diff --git a/tests/test_tx.py b/tests/test_tx.py index 0bc7ac82635349dddd9b239dbfffdb6b6e82a7a1..bc055d1392ad3c319265d5e3e914b2cc378cfd05 100644 --- a/tests/test_tx.py +++ b/tests/test_tx.py @@ -13,7 +13,6 @@ # 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 from unittest.mock import Mock import pytest @@ -23,7 +22,6 @@ from click.testing import CliRunner from patched.auth import patched_auth_method from patched.money import patched_get_sources, patched_get_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 ( @@ -119,11 +117,6 @@ def test_transaction_amount_errors( return True return False - # run tests - if amounts: - given_amounts = amounts - if UDs_amounts: - given_amounts = UDs_amounts # check program exit on error with pytest.raises(SystemExit) as pytest_exit: # read output to check error. diff --git a/tests/test_tx_file.py b/tests/test_tx_file.py index 48b00a35f554809ad8cfc54f59ceb76a0329ca5d..1c02a44ee10309c20121c1ce303f1244b2eb82fc 100644 --- a/tests/test_tx_file.py +++ b/tests/test_tx_file.py @@ -74,6 +74,6 @@ def test_parse_file_containing_amounts_recipients_errors(file_content, error, ca with runner.isolated_filesystem(): with open(FILE_PATH, "w") as f: f.write(file_content) - with pytest.raises(SystemExit) as pytest_exit: + with pytest.raises(SystemExit): parse_file_containing_amounts_recipients(FILE_PATH) assert error in capsys.readouterr().out diff --git a/tests/test_tx_history.py b/tests/test_tx_history.py index e89b4da674cffc9a2cc0c2c151e895416a934e4c..496686c16b82e66e3128b1132fdda2240a561d02 100644 --- a/tests/test_tx_history.py +++ b/tests/test_tx_history.py @@ -18,13 +18,8 @@ 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, - PUBKEY_MAX_LENGTH, - PUBKEY_MIN_LENGTH, - SHORT_PUBKEY_SIZE, -) +from silkaj import tx_history, wot_tools +from silkaj.constants import PUBKEY_MAX_LENGTH, PUBKEY_MIN_LENGTH, SHORT_PUBKEY_SIZE from silkaj.crypto_tools import CHECKSUM_SIZE SHORT_PUBKEY_LENGTH_WITH_CHECKSUM = ( @@ -110,7 +105,7 @@ def test_tx_history_generate_table_and_pubkey_uid_display(monkeypatch): for tx_list in txs_list_full: assert len(tx_list) == table_columns if tx_list != txs_list_full[0]: - assert not "…:" in tx_list[1] + assert "…:" not in tx_list[1] assert ":" in tx_list[1] # this length is not true for multisig txs, which are very unlikely for now. assert ( @@ -131,7 +126,7 @@ def test_tx_history_generate_table_and_pubkey_uid_display(monkeypatch): for tx_list in txs_list_uids_full: assert len(tx_list) == table_columns if tx_list != txs_list_uids_full[0]: - assert not "…:" in tx_list[1] + assert "…:" not in tx_list[1] assert ":" in tx_list[1] # check all lines assert len(txs_list_uids_full[1][1]) >= min_pubkey_length_with_uid( diff --git a/tests/test_unit_cert.py b/tests/test_unit_cert.py index 41610821a35d1db4d3392bf66dd3aa60a4857625..994df17ea8dc2660a8f216af67c344776a37d417 100644 --- a/tests/test_unit_cert.py +++ b/tests/test_unit_cert.py @@ -13,10 +13,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 unittest.mock import patch - -from silkaj.cert import certification_confirmation - +# 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 ced3d49d030301dd7381aad1379ef8cac078c10d..1b718f72c7d1c8f91e89b0f184dc7ab6ea21b692 100644 --- a/tests/test_unit_tx.py +++ b/tests/test_unit_tx.py @@ -31,23 +31,10 @@ from patched.blockchain_tools import fake_block_id, patched_get_head_block from patched.money import patched_get_sources, patched_get_ud_value from patched.test_constants import mock_ud_value from patched.tools import patched_get_currency_symbol -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 import auth, blockchain_tools, money, network_tools, tools, tx, wot_tools from silkaj.cli import cli -from silkaj.constants import CENT_MULT_TO_UNIT, G1_SYMBOL, MINIMAL_ABSOLUTE_TX_AMOUNT +from silkaj.constants import CENT_MULT_TO_UNIT, G1_SYMBOL from silkaj.tui import display_amount, display_pubkey # Values @@ -847,7 +834,7 @@ def test_handle_intermediaries_transactions( key, issuers, tx_amounts, outputAddresses, Comment, OutputbackChange ) - if expected_listinput_amount[2] == True: + if expected_listinput_amount[2]: patched_generate_and_send_transaction.assert_any_call( key, issuers, @@ -1014,7 +1001,7 @@ def test_send_transaction( if comment: args_list.append("--comment") args_list.append(comment) - if outputbackchange != None: + if outputbackchange is not None: args_list.append("--outputBackChange") args_list.append(outputbackchange) return args_list @@ -1402,7 +1389,7 @@ def test_check_transaction_values_errors( comment, outputAddresses, outputBackChange, enough_source, issuer_pubkey, capsys ): with pytest.raises(SystemExit) as pytest_exit: - result = tx.check_transaction_values( + tx.check_transaction_values( comment, outputAddresses, outputBackChange, enough_source, issuer_pubkey ) assert pytest_exit.type == SystemExit