From fd5eb09b68a6a016d286022f9efdd6f45b78211d Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Sun, 5 Mar 2023 18:39:50 +0100 Subject: [PATCH] Apply ruff changes (#458) --- silkaj/about.py | 2 +- silkaj/auth.py | 2 +- silkaj/blockchain/blocks.py | 2 +- silkaj/blockchain/difficulty.py | 2 +- silkaj/blockchain/verify.py | 23 ++- silkaj/g1_monetary_license.py | 2 +- silkaj/money/balance.py | 16 +- silkaj/money/history.py | 48 ++++-- silkaj/money/tools.py | 10 +- silkaj/money/transfer.py | 68 +++++---- silkaj/network.py | 2 +- silkaj/public_key.py | 2 +- silkaj/tools.py | 2 +- silkaj/wot/certification.py | 23 +-- silkaj/wot/idty_tools.py | 6 +- silkaj/wot/membership.py | 14 +- silkaj/wot/revocation.py | 6 +- silkaj/wot/status.py | 24 ++- silkaj/wot/tools.py | 2 +- tests/integration/blockchain/test_verify.py | 12 +- tests/integration/test_end_to_end.py | 12 +- tests/integration/wot/test_membership.py | 4 +- tests/patched/blockchain_tools.py | 3 +- tests/patched/idty_tools.py | 14 +- tests/patched/money.py | 10 +- tests/patched/tx.py | 6 +- tests/patched/tx_history.py | 14 +- tests/patched/wot.py | 11 +- tests/unit/blockchain/test_verify.py | 4 +- tests/unit/money/test_history.py | 10 +- tests/unit/money/test_tools.py | 15 +- tests/unit/money/test_transfer.py | 157 ++++++++++++++++---- tests/unit/money/test_transfer_cli.py | 54 ++++--- tests/unit/money/test_transfer_file.py | 9 +- tests/unit/test_auth.py | 5 +- tests/unit/test_checksum.py | 2 +- tests/unit/test_g1_monetary_license.py | 4 +- tests/unit/test_network.py | 4 +- tests/unit/test_public_key.py | 16 +- tests/unit/test_tui.py | 8 +- tests/unit/wot/test_idty_tools.py | 56 ++++--- tests/unit/wot/test_membership.py | 12 +- tests/unit/wot/test_revocation.py | 64 +++++--- tests/unit/wot/test_tools.py | 13 +- 44 files changed, 498 insertions(+), 277 deletions(-) diff --git a/silkaj/about.py b/silkaj/about.py index 878d1781..7bec9b82 100644 --- a/silkaj/about.py +++ b/silkaj/about.py @@ -30,7 +30,7 @@ def about() -> None: \n @@ @@@ @@@@@@@@@@@ @@,\ \n @@ @@@ &@@@@@@@@@@@@@ @@@ Powerfull and lightweight command line client\ \n @@ @@@ @@@@@@@@@# @@@@ @@(\ -\n @@ @@@@ @@@@@@@@@ @@@ @@ Built in Python for Duniter’s currencies: \ +\n @@ @@@@ @@@@@@@@@ @@@ @@ Built in Python for Duniter`s currencies: \ Ğ1 and Ğ1-Test\ \n @@ @@@ @@@@@@@@ @ @@@ @@\ \n @@ @@@ @@@@@@ @@@@ @@ @@ Authors: see AUTHORS.md file\ diff --git a/silkaj/auth.py b/silkaj/auth.py index e2108ae8..fa669224 100644 --- a/silkaj/auth.py +++ b/silkaj/auth.py @@ -135,7 +135,7 @@ def auth_by_scrypt(ctx: Context) -> SigningKey: def auth_by_wif() -> SigningKey: wif_hex = getpass("Enter your WIF or Encrypted WIF address (masked): ") password = getpass( - "(Leave empty in case WIF format) Enter the Encrypted WIF password (masked): " + "(Leave empty in case WIF format) Enter the Encrypted WIF password (masked): ", ) try: return SigningKey.from_wif_or_ewif_hex(wif_hex, password) diff --git a/silkaj/blockchain/blocks.py b/silkaj/blockchain/blocks.py index 5aa33297..04daed80 100644 --- a/silkaj/blockchain/blocks.py +++ b/silkaj/blockchain/blocks.py @@ -59,7 +59,7 @@ def list_blocks(number: int, detailed: bool) -> None: issuer["powMin"] = block["powMin"] issuers_dict[issuer["pubkey"]] = issuer issuers.append(issuer) - for pubkey in issuers_dict.keys(): + for pubkey in issuers_dict: issuer = issuers_dict[pubkey] time.sleep(BMA_SLEEP) try: diff --git a/silkaj/blockchain/difficulty.py b/silkaj/blockchain/difficulty.py index 4b01c3c8..af05d6fa 100644 --- a/silkaj/blockchain/difficulty.py +++ b/silkaj/blockchain/difficulty.py @@ -89,4 +89,4 @@ def compute_power(nbr: float, power: int = 0) -> str: while nbr >= 10: nbr /= 10 power += 1 - return f"{nbr:.1f} × 10^{power}" + return f"{nbr:.1f} x 10^{power}" diff --git a/silkaj/blockchain/verify.py b/silkaj/blockchain/verify.py index a3921520..d78b20be 100644 --- a/silkaj/blockchain/verify.py +++ b/silkaj/blockchain/verify.py @@ -29,7 +29,7 @@ from silkaj.tools import message_exit @command( "verify", - help="Verify blocks’ signatures. \ + help="Verify blocks` signatures. \ If only FROM_BLOCK is specified, it verifies from this block to the last block. \ If nothing specified, the whole blockchain gets verified.", ) @@ -51,8 +51,10 @@ def verify_blocks_signatures(from_block: int, to_block: int) -> None: chunk = get_chunk(client, chunk_size, chunk_from) for block in chunk: - block = Block.from_signed_raw(f'{block["raw"]}{block["signature"]}\n') - verify_block_signature(invalid_blocks_signatures, block) + block_obj = Block.from_signed_raw( + f'{block["raw"]}{block["signature"]}\n', + ) + verify_block_signature(invalid_blocks_signatures, block_obj) display_result(from_block, to_block, invalid_blocks_signatures) @@ -63,7 +65,7 @@ def check_passed_blocks_range(client: Client, from_block: int, to_block: int) -> to_block = head_number if to_block > head_number: message_exit( - f"Passed TO_BLOCK argument is bigger than the head block: {str(head_number)}" + f"Passed TO_BLOCK argument is bigger than the head block: {str(head_number)}", ) if from_block > to_block: message_exit("TO_BLOCK should be bigger or equal to FROM_BLOCK") @@ -71,7 +73,10 @@ def check_passed_blocks_range(client: Client, from_block: int, to_block: int) -> def get_chunk_size( - from_block: int, to_block: int, chunks_from: range, chunk_from: int + from_block: int, + to_block: int, + chunks_from: range, + chunk_from: int, ) -> int: """If not last chunk, take the maximum size Otherwise, calculate the size for the last chunk""" @@ -83,8 +88,8 @@ def get_chunk_size( def get_chunk(client: Client, chunk_size: int, chunk_from: int) -> List: try: chunk = client(bma.blockchain.blocks, chunk_size, chunk_from) - except HTTPError as e: - logging.error(e) + except HTTPError: + logging.exception("Network error to get chunck") message_exit("Error: Network error to get chunck") return chunk @@ -95,7 +100,9 @@ def verify_block_signature(invalid_blocks_signatures: List[int], block: Block) - def display_result( - from_block: int, to_block: int, invalid_blocks_signatures: List[int] + from_block: int, + to_block: int, + invalid_blocks_signatures: List[int], ) -> None: result = f"Within {from_block}-{to_block} range, " if invalid_blocks_signatures: diff --git a/silkaj/g1_monetary_license.py b/silkaj/g1_monetary_license.py index 635e21ed..ea623c3c 100644 --- a/silkaj/g1_monetary_license.py +++ b/silkaj/g1_monetary_license.py @@ -24,7 +24,7 @@ def license_approval(currency: str) -> None: if currency != "g1": return if click.confirm( - "You will be asked to approve Ğ1 license. Would you like to display it?" + "You will be asked to approve Ğ1 license. Would you like to display it?", ): g1ml = G1MonetaryLicense() g1ml.display_license() diff --git a/silkaj/money/balance.py b/silkaj/money/balance.py index af5f2eff..552e15b0 100644 --- a/silkaj/money/balance.py +++ b/silkaj/money/balance.py @@ -47,7 +47,7 @@ def balance_cmd(ctx: Context, pubkeys: str) -> None: print(f"ERROR: pubkey {pubkey} has a wrong format") if pubkey in pubkeys_list: sys.exit( - f"ERROR: pubkey {gen_pubkey_checksum(pubkey)} was specified many times" + f"ERROR: pubkey {gen_pubkey_checksum(pubkey)} was specified many times", ) pubkeys_list.append(pubkey) if wrong_pubkeys: @@ -92,7 +92,11 @@ def show_amount_from_pubkey(label: str, inputs_balance: List[int]) -> None: if totalAmountInput - balance != 0: m_tools.display_amount( - display, "Blockchain", balance, ud_value, currency_symbol + display, + "Blockchain", + balance, + ud_value, + currency_symbol, ) m_tools.display_amount( display, @@ -102,13 +106,17 @@ def show_amount_from_pubkey(label: str, inputs_balance: List[int]) -> None: currency_symbol, ) m_tools.display_amount( - display, "Total balance", totalAmountInput, ud_value, currency_symbol + display, + "Total balance", + totalAmountInput, + ud_value, + currency_symbol, ) display.append( [ "Total relative to M/N", f"{round(totalAmountInput / average, 2)} x M/N", - ] + ], ) table = tui.Table() diff --git a/silkaj/money/history.py b/silkaj/money/history.py index 81b777b9..52d50d1f 100644 --- a/silkaj/money/history.py +++ b/silkaj/money/history.py @@ -59,7 +59,13 @@ def transaction_history(pubkey: str, uids: bool, full_pubkey: bool) -> None: remove_duplicate_txs(received_txs, sent_txs) txs_list = generate_txs_list( - received_txs, sent_txs, pubkey, ud_value, currency_symbol, uids, full_pubkey + received_txs, + sent_txs, + pubkey, + ud_value, + currency_symbol, + uids, + full_pubkey, ) table_headers = [ "Date", @@ -77,7 +83,7 @@ def generate_header(pubkey: str, currency_symbol: str, ud_value: int) -> str: try: idty = wt.identity_of(pubkey) except HTTPError: - idty = dict([("uid", "")]) + idty = {"uid": ""} balance = get_amount_from_pubkey(pubkey) balance_ud = round(balance[1] / ud_value, 2) date = now().format(ALL) @@ -86,7 +92,10 @@ Current balance: {balance[1] / 100} {currency_symbol}, {balance_ud} UD {currency def get_transactions_history( - client: Client, pubkey: str, received_txs: List, sent_txs: List + client: Client, + pubkey: str, + received_txs: List, + sent_txs: List, ) -> None: """ Get transaction history @@ -105,7 +114,7 @@ def remove_duplicate_txs(received_txs: List, sent_txs: List) -> None: """ Remove duplicate transactions from history Remove received tx which contains output back return - that we don’t want to displayed + that we don`t want to displayed A copy of received_txs is necessary to remove elements """ for received_tx in list(received_txs): @@ -133,7 +142,12 @@ def generate_txs_list( [], ) # type: List[Transaction], List[Transaction] parse_received_tx( - received_txs_list, received_txs, pubkey, ud_value, uids, full_pubkey + received_txs_list, + received_txs, + pubkey, + ud_value, + uids, + full_pubkey, ) parse_sent_tx(sent_txs_list, sent_txs, pubkey, ud_value, uids, full_pubkey) txs_list = received_txs_list + sent_txs_list @@ -151,7 +165,7 @@ def parse_received_tx( full_pubkey: bool, ) -> None: """ - Extract issuers’ pubkeys + Extract issuers` pubkeys Get identities from pubkeys Convert time into human format Assign identities @@ -169,7 +183,9 @@ def parse_received_tx( tx_list.append("") for i, issuer in enumerate(received_tx.issuers): tx_list[1] += prefix(None, None, i) + assign_idty_from_pubkey( - issuer, identities, full_pubkey + issuer, + identities, + full_pubkey, ) amounts = tx_amount(received_tx, pubkey, received_func)[0] tx_list.append(amounts / 100) @@ -188,7 +204,7 @@ def parse_sent_tx( ) -> None: # pylint: disable=too-many-locals """ - Extract recipients’ pubkeys from outputs + Extract recipients` pubkeys from outputs Get identities from pubkeys Convert time into human format Store "Total" and total amounts according to the number of outputs @@ -220,13 +236,15 @@ def parse_sent_tx( for i, output in enumerate(outputs): if output_available(output.condition, ne, pubkey): amounts += prefix(None, outputs, i) + str( - neg(amount_in_current_base(output)) / 100 + neg(amount_in_current_base(output)) / 100, ) amounts_ud += prefix(None, outputs, i) + str( - round(neg(amount_in_current_base(output)) / ud_value, 2) + round(neg(amount_in_current_base(output)) / ud_value, 2), ) tx_list[1] += prefix(tx_list[1], outputs, 0) + assign_idty_from_pubkey( - output.condition.left.pubkey, identities, full_pubkey + output.condition.left.pubkey, + identities, + full_pubkey, ) tx_list.append(amounts) tx_list.append(amounts_ud) @@ -235,7 +253,9 @@ def parse_sent_tx( def tx_amount( - tx: List[Transaction], pubkey: str, function: Any + tx: List[Transaction], + pubkey: str, + function: Any, ) -> Tuple[int, List[OutputSource]]: """ Determine transaction amount from output sources @@ -282,7 +302,9 @@ def assign_idty_from_pubkey(pubkey: str, identities: List, full_pubkey: bool) -> def prefix( - tx_addresses: Optional[str], outputs: Optional[List[OutputSource]], occurence: int + tx_addresses: Optional[str], + outputs: Optional[List[OutputSource]], + occurence: int, ) -> str: """ Pretty print with texttable diff --git a/silkaj/money/tools.py b/silkaj/money/tools.py index cfceba62..47bebc42 100644 --- a/silkaj/money/tools.py +++ b/silkaj/money/tools.py @@ -25,7 +25,11 @@ from silkaj.wot import tools as wt def display_amount( - tx: List, message: str, amount: float, ud_value: float, currency_symbol: str + tx: List, + message: str, + amount: float, + ud_value: float, + currency_symbol: str, ) -> None: """ Displays an amount in unit and relative reference. @@ -36,7 +40,7 @@ def display_amount( [ f"{message} (unit|relative)", f"{unit_amount} {currency_symbol} | {UD_amount} UD {currency_symbol}", - ] + ], ) @@ -75,7 +79,7 @@ def get_sources(pubkey: str) -> Tuple[List[InputSource], int]: source=source["type"], origin_id=source["identifier"], index=source["noffset"], - ) + ), ) amount += amount_in_current_base(listinput[-1]) diff --git a/silkaj/money/transfer.py b/silkaj/money/transfer.py index 1ef7a5e6..0d32cd2c 100644 --- a/silkaj/money/transfer.py +++ b/silkaj/money/transfer.py @@ -93,7 +93,7 @@ NBR_ISSUERS = 1 "--recipient", "-r", multiple=True, - help="Pubkey(s)’ recipients + optional checksum:\n-r <pubkey>[:checksum]\n\ + help="Pubkey(s)` recipients + optional checksum:\n-r <pubkey>[:checksum]\n\ Sending to many recipients is possible:\n\ * With one amount, all will receive the amount\n\ * With many amounts (one per recipient)", @@ -104,8 +104,8 @@ Sending to many recipients is possible:\n\ "file_path", "--file", "-f", - help="File’s path containing a list of amounts in absolute or \ -relative reference and recipients’ pubkeys", + help="File`s path containing a list of amounts in absolute or \ +relative reference and recipients` pubkeys", cls=tools.MutuallyExclusiveOption, mutually_exclusive=["recipients", "amounts", "amountsUD", "allsources"], ) @@ -115,7 +115,10 @@ relative reference and recipients’ pubkeys", help="Pubkey recipient to send the rest of the transaction: <pubkey[:checksum]>", ) @click.option( - "--yes", "-y", is_flag=True, help="Assume yes. Do not prompt confirmation" + "--yes", + "-y", + is_flag=True, + help="Assume yes. Do not prompt confirmation", ) def transfer_money( amounts: List[float], @@ -136,7 +139,7 @@ def transfer_money( tools.message_exit("Error: A recipient should be passed") if allsources and len(recipients) > 1: tools.message_exit( - "Error: the --allSources option can only be used with one recipient." + "Error: the --allSources option can only be used with one recipient.", ) # compute amounts and amountsud if not allsources: @@ -150,7 +153,7 @@ def transfer_money( if pubkey_amount[0] <= 0: tools.message_exit( f"Error: Issuer pubkey {gen_pubkey_checksum(issuer_pubkey)} is empty. \ -No transaction sent." +No transaction sent.", ) tx_amounts = [pubkey_amount[0]] @@ -179,7 +182,7 @@ No transaction sent." confirmation_table = table.draw() if yes or click.confirm( - f"{confirmation_table}\nDo you confirm sending this transaction?" + f"{confirmation_table}\nDo you confirm sending this transaction?", ): handle_intermediaries_transactions( key, @@ -202,9 +205,9 @@ def parse_file_containing_amounts_recipients( [ABSOLUTE/RELATIVE] # comment1 - amount1 recipient1’s pubkey + amount1 recipient1`s pubkey # comment2 - amount2 recipient2’s pubkey + amount2 recipient2`s pubkey ``` """ reference = "" @@ -224,24 +227,25 @@ def parse_file_containing_amounts_recipients( if not reference or reference not in ("ABSOLUTE", "RELATIVE"): tools.message_exit( - f"{file_path} must contain at first line 'ABSOLUTE' or 'RELATIVE' header" + f"{file_path} must contain at first line 'ABSOLUTE' or 'RELATIVE' header", ) if not amounts or not recipients: tools.message_exit("No amounts or recipients specified") # Compute amount depending on the reference - if reference == "ABSOLUTE": - reference_mult = CENT_MULT_TO_UNIT - else: - reference_mult = m_tools.get_ud_value() + reference_mult = ( + CENT_MULT_TO_UNIT if reference == "ABSOLUTE" else m_tools.get_ud_value() + ) tx_amounts = compute_amounts(amounts, reference_mult) return tx_amounts, recipients def transaction_amount( - amounts: List[float], UDs_amounts: List[float], outputAddresses: List[str] + amounts: List[float], + UDs_amounts: List[float], + outputAddresses: List[str], ) -> List[int]: """ Check that the number of passed amounts(UD) and recipients are the same @@ -255,7 +259,7 @@ def transaction_amount( amounts_list = compute_amounts(UDs_amounts, UD_value) if len(amounts_list) != len(outputAddresses) and len(amounts_list) != 1: tools.message_exit( - "Error: The number of passed recipients is not the same as the passed amounts." + "Error: The number of passed recipients is not the same as the passed amounts.", ) # In case one amount is passed with multiple recipients # generate list containing multiple time the same amount @@ -300,18 +304,17 @@ def check_transaction_values( # we check output numbers and leave one line for the backchange. if len(outputAddresses) > (MAX_OUTPUTS - 1): tools.message_exit( - f"Error : there should be less than {MAX_OUTPUTS - 1} outputs." + f"Error : there should be less than {MAX_OUTPUTS - 1} outputs.", ) for i, outputAddress in enumerate(outputAddresses): if public_key.check_pubkey_format(outputAddress): outputAddresses[i] = public_key.validate_checksum(outputAddress) - if outputBackChange: - if public_key.check_pubkey_format(outputBackChange): - outputBackChange = public_key.validate_checksum(outputBackChange) + if outputBackChange and public_key.check_pubkey_format(outputBackChange): + outputBackChange = public_key.validate_checksum(outputBackChange) if enough_source: pubkey = gen_pubkey_checksum(issuer_pubkey) tools.message_exit( - f"{pubkey} pubkey doesn’t have enough money for this transaction." + f"{pubkey} pubkey doesn`t have enough money for this transaction.", ) return outputBackChange @@ -368,7 +371,9 @@ def gen_confirmation_table( def get_list_input_for_transaction( - pubkey: str, TXamount: int, outputs_number: int + pubkey: str, + TXamount: int, + outputs_number: int, ) -> Tuple[List[InputSource], int, bool]: listinput = m_tools.get_sources(pubkey)[0] maxInputsNumber = max_inputs_number(outputs_number, NBR_ISSUERS) @@ -382,7 +387,7 @@ def get_list_input_for_transaction( TXamount -= m_tools.amount_in_current_base(_input) # if too much sources, it's an intermediate transaction. amount_not_reached_and_max_doc_size_reached = ( - TXamount > 0 and MAX_INPUTS_PER_TX <= nbr_inputs + TXamount > 0 and nbr_inputs >= MAX_INPUTS_PER_TX ) amount_reached_too_much_inputs = TXamount <= 0 and maxInputsNumber < nbr_inputs if ( @@ -394,7 +399,7 @@ def get_list_input_for_transaction( # if we gather the good amount, we send the tx : # - either this is no int.tx, and the tx is sent to the receiver, # - or the int.tx it is sent to the issuer before sent to the receiver. - if MAX_INPUTS_PER_TX <= nbr_inputs or TXamount <= 0: + if nbr_inputs >= MAX_INPUTS_PER_TX or TXamount <= 0: break if TXamount > 0 and not intermediatetransaction: tools.message_exit("Error: you don't have enough money") @@ -412,7 +417,9 @@ def handle_intermediaries_transactions( while True: # consider there is always one backchange output, hence +1 listinput_and_amount = get_list_input_for_transaction( - issuers, sum(tx_amounts), len(outputAddresses) + 1 + issuers, + sum(tx_amounts), + len(outputAddresses) + 1, ) intermediatetransaction = listinput_and_amount[2] @@ -446,7 +453,7 @@ def max_inputs_number(outputs_number: int, issuers_number: int) -> int: formula is IU <= (MAX_LINES_IN_TX_DOC - FIX_LINES - O - 2*IS)/2 """ return int( - (MAX_LINES_IN_TX_DOC - FIX_LINES - (2 * issuers_number) - outputs_number) / 2 + (MAX_LINES_IN_TX_DOC - FIX_LINES - (2 * issuers_number) - outputs_number) / 2, ) @@ -554,7 +561,10 @@ def generate_unlocks(listinput: List[InputSource]) -> List[Unlock]: def generate_output( - listoutput: List[OutputSource], unitbase: int, rest: int, recipient_address: str + listoutput: List[OutputSource], + unitbase: int, + rest: int, + recipient_address: str, ) -> None: while rest > 0: outputAmount = truncBase(rest, unitbase) @@ -566,7 +576,7 @@ def generate_output( amount=outputAmount, base=unitbase, condition=f"SIG({recipient_address})", - ) + ), ) unitbase = unitbase - 1 @@ -576,7 +586,7 @@ def checkComment(comment: str) -> None: tools.message_exit("Error: Comment is too long") regex = re.compile( "^[0-9a-zA-Z\\ \\-\\_\\:\\/\\;\\*\\[\\]\\(\\)\\?\ -\\!\\^\\+\\=\\@\\&\\~\\#\\{\\}\\|\\\\<\\>\\%\\.]*$" +\\!\\^\\+\\=\\@\\&\\~\\#\\{\\}\\|\\\\<\\>\\%\\.]*$", ) if not re.search(regex, comment): tools.message_exit("Error: the format of the comment is invalid") diff --git a/silkaj/network.py b/silkaj/network.py index 74f1f96a..83425022 100644 --- a/silkaj/network.py +++ b/silkaj/network.py @@ -54,7 +54,7 @@ def determine_endpoint() -> ep.Endpoint: if not m: sys.exit( "Error: Passed endpoint is of wrong format.\n\ -Expected format: {host|ipv4|[ipv6]}:{port}{/path}" +Expected format: {host|ipv4|[ipv6]}:{port}{/path}", ) port = int(m["port"]) if m["port"] else 443 host, ipv4 = ep.fix_host_ipv4_mix_up(m["host"], m["ipv4"]) diff --git a/silkaj/public_key.py b/silkaj/public_key.py index 4d40f3c1..c6d6dceb 100644 --- a/silkaj/public_key.py +++ b/silkaj/public_key.py @@ -67,7 +67,7 @@ def validate_checksum(pubkey_checksum: str) -> Any: return pubkey message_exit( f"Error: public key '{pubkey}' does not match checksum '{checksum}'.\n\ -Please verify the public key." +Please verify the public key.", ) return None diff --git a/silkaj/tools.py b/silkaj/tools.py index b85f9fad..88c51e61 100644 --- a/silkaj/tools.py +++ b/silkaj/tools.py @@ -52,7 +52,7 @@ class MutuallyExclusiveOption(click.Option): if self.mutually_exclusive.intersection(opts) and self.name in opts: arguments = ", ".join(self.mutually_exclusive) raise click.UsageError( - f"Usage: `{self.name}` is mutually exclusive with arguments `{arguments}`." + f"Usage: `{self.name}` is mutually exclusive with arguments `{arguments}`.", ) return super().handle_parse_result(ctx, opts, args) diff --git a/silkaj/wot/certification.py b/silkaj/wot/certification.py index 168649b5..573d3b14 100644 --- a/silkaj/wot/certification.py +++ b/silkaj/wot/certification.py @@ -45,7 +45,7 @@ def certify(ctx: click.Context, uid_pubkey_to_certify: str) -> None: # pylint: disable=unused-variable idty_to_certify, pubkey_to_certify, send_certs = wot_tools.choose_identity( - uid_pubkey_to_certify + uid_pubkey_to_certify, ) # Authentication @@ -61,7 +61,11 @@ def certify(ctx: click.Context, uid_pubkey_to_certify: str) -> None: # Certification confirmation certification_confirmation( - ctx, issuer, issuer_pubkey, pubkey_to_certify, idty_to_certify + ctx, + issuer, + issuer_pubkey, + pubkey_to_certify, + idty_to_certify, ) # Create and sign certification document @@ -89,7 +93,7 @@ def pre_checks(client: Client, issuer_pubkey: str, pubkey_to_certify: str) -> Di sys.exit("Current identity is not member.") if issuer_pubkey == pubkey_to_certify: - sys.exit("You can’t certify yourself!") + sys.exit("You can`t certify yourself!") # Check if the certification can be renewed params = bc_tools.get_blockchain_parameters() @@ -97,8 +101,8 @@ def pre_checks(client: Client, issuer_pubkey: str, pubkey_to_certify: str) -> Di req = requirements["identities"][0] # type: Dict for cert in req["certifications"]: if cert["from"] == issuer_pubkey: - # Ğ1: 0<–>2y - 2y + 2m - # ĞT: 0<–>4.8m - 4.8m + 12.5d + # Ğ1: 0<->2y - 2y + 2m + # ĞT: 0<->4.8m - 4.8m + 12.5d renewable = cert["expiresIn"] - params["sigValidity"] + params["sigReplay"] if renewable > 0: renewable_date = now().add(seconds=renewable).format(DATE) @@ -125,14 +129,14 @@ def certification_confirmation( block = client(bma.blockchain.block, block_id_idty.number) timestamp_date = from_timestamp(block["time"], tz="local").format(ALL) block_id_date = f": #{idty_timestamp[:15]}… {timestamp_date}" - cert.append(["ID", issuer["uid"], "–>", idty_to_certify["uid"] + block_id_date]) + cert.append(["ID", issuer["uid"], "->", idty_to_certify["uid"] + block_id_date]) cert.append( [ "Pubkey", gen_pubkey_checksum(issuer_pubkey), - "–>", + "->", gen_pubkey_checksum(pubkey_to_certify), - ] + ], ) params = bc_tools.get_blockchain_parameters() cert_ends = now().add(seconds=params["sigValidity"]).format(DATE) @@ -140,7 +144,8 @@ def certification_confirmation( table = tui.Table() table.fill_rows( - cert, ["Cert", "Issuer", "–>", "Recipient: Published: #block-hash date"] + cert, + ["Cert", "Issuer", "->", "Recipient: Published: #block-hash date"], ) click.echo(table.draw()) diff --git a/silkaj/wot/idty_tools.py b/silkaj/wot/idty_tools.py index 3aa1c8a1..05523e09 100644 --- a/silkaj/wot/idty_tools.py +++ b/silkaj/wot/idty_tools.py @@ -41,7 +41,7 @@ def display_identity(idty: Identity) -> Texttable: id_table.append(["Blockstamp", str(idty.block_id)]) creation_block = client(bma.blockchain.block, idty.block_id.number) creation_date = pendulum.from_timestamp(creation_block["time"], tz="local").format( - ALL + ALL, ) id_table.append(["Created on", creation_date]) # display infos @@ -65,7 +65,7 @@ def check_many_identities(document: Union[Identity, Revocation]) -> bool: except urllib.error.HTTPError: sys.exit( f"{error_no_identical_id}\nuid: {idty.uid}\npubkey: \ -{gen_pubkey_checksum(idty.pubkey)}" +{gen_pubkey_checksum(idty.pubkey)}", ) # get all matching identities @@ -91,7 +91,7 @@ def display_alternate_ids(ids_list: List) -> Texttable: table.header(labels) for _id in ids_list: table.add_row( - [_id.uid, gen_pubkey_checksum(_id.pubkey), str(_id.block_id)[:12]] + [_id.uid, gen_pubkey_checksum(_id.pubkey), str(_id.block_id)[:12]], ) return table diff --git a/silkaj/wot/membership.py b/silkaj/wot/membership.py index 74b4ea84..26220daa 100644 --- a/silkaj/wot/membership.py +++ b/silkaj/wot/membership.py @@ -85,7 +85,9 @@ def send_membership(ctx: click.Context) -> None: def display_confirmation_table( - identity_uid: str, pubkey: str, identity_block_id: BlockID + identity_uid: str, + pubkey: str, + identity_block_id: BlockID, ) -> None: """ Check whether there is pending memberships already in the mempool @@ -115,14 +117,14 @@ def display_confirmation_table( [ "Number of pending membership(s) in the mempool", len(pending_memberships), - ] + ], ) table.append( [ "Pending membership documents will expire", pendulum.now().add(seconds=pending_expires).diff_for_humans(), - ] + ], ) table.append(["User Identifier (UID)", identity_uid]) @@ -135,7 +137,7 @@ def display_confirmation_table( [ "Identity published", pendulum.from_timestamp(block["time"], tz="local").format(DATE), - ] + ], ) params = bc_tools.get_blockchain_parameters() @@ -143,14 +145,14 @@ def display_confirmation_table( [ "Expiration date of new membership", pendulum.now().add(seconds=params["msValidity"]).diff_for_humans(), - ] + ], ) table.append( [ "Expiration date of new membership from the mempool", pendulum.now().add(seconds=params["msPeriod"]).diff_for_humans(), - ] + ], ) display_table = tui.Table() diff --git a/silkaj/wot/revocation.py b/silkaj/wot/revocation.py index f6bfcab5..1d83396d 100644 --- a/silkaj/wot/revocation.py +++ b/silkaj/wot/revocation.py @@ -160,7 +160,7 @@ def warn_before_sending_document() -> None: click.echo( "This identity will be revoked.\n\ It will cease to be member and to create the Universal Dividend.\n\ -All currently sent certifications will remain valid until they expire." +All currently sent certifications will remain valid until they expire.", ) tui.send_doc_confirmation("revocation document immediately") @@ -190,7 +190,7 @@ def save_doc(path: str, content: str, pubkey: str) -> None: if rev_path.is_file(): if click.confirm( f"Would you like to erase existing file `{path}` with the \ -generated revocation document corresponding to {pubkey_cksum} public key?" +generated revocation document corresponding to {pubkey_cksum} public key?", ): rev_path.unlink() else: @@ -200,7 +200,7 @@ generated revocation document corresponding to {pubkey_cksum} public key?" with open(rev_path, "w", encoding="utf-8") as file: file.write(content) click.echo( - f"Revocation document file stored into `{path}` for following public key: {pubkey_cksum}" + f"Revocation document file stored into `{path}` for following public key: {pubkey_cksum}", ) diff --git a/silkaj/wot/status.py b/silkaj/wot/status.py index 76887832..7c4f9456 100644 --- a/silkaj/wot/status.py +++ b/silkaj/wot/status.py @@ -29,7 +29,9 @@ from silkaj.wot import tools as wt def get_sent_certifications( - signed: List, time_first_block: int, params: Dict + signed: List, + time_first_block: int, + params: Dict, ) -> Tuple[List[str], List[str]]: sent = [] expire = [] @@ -38,8 +40,10 @@ def get_sent_certifications( sent.append(cert["uid"]) expire.append( expiration_date_from_block_id( - cert["cert_time"]["block"], time_first_block, params - ) + cert["cert_time"]["block"], + time_first_block, + params, + ), ) return sent, expire @@ -81,11 +85,13 @@ def status(uid_pubkey: str) -> None: for cert in identity["others"]: certifications["received_expire"].append( expiration_date_from_block_id( - cert["meta"]["block_number"], time_first_block, params - ) + cert["meta"]["block_number"], + time_first_block, + params, + ), ) certifications["received"].append( - cert_written_in_the_blockchain(req["certifications"], cert) + cert_written_in_the_blockchain(req["certifications"], cert), ) ( certifications["sent"], @@ -102,7 +108,7 @@ from block #{identity["meta"]["timestamp"][:15]}…\n\ received {len(certifications["received"])} and sent \ {nbr_sent_certs}/{params["sigStock"]} certifications:\n\ {table.draw()}\n\ -✔: Certification available to be written or already written into the blockchain\n' +✔: Certification available to be written or already written into the blockchain\n', ) membership_status(certifications, pubkey, req) @@ -137,7 +143,9 @@ def membership_status(certifications: OrderedDict, pubkey: str, req: Dict) -> No def expiration_date_from_block_id( - block_id: str, time_first_block: int, params: Dict + block_id: str, + time_first_block: int, + params: Dict, ) -> str: expir_timestamp = ( date_approximation(block_id, time_first_block, params["avgGenTime"]) diff --git a/silkaj/wot/tools.py b/silkaj/wot/tools.py index e50cd091..1899f0d6 100644 --- a/silkaj/wot/tools.py +++ b/silkaj/wot/tools.py @@ -103,7 +103,7 @@ def choose_identity(pubkey_uid: str) -> Tuple[Dict, str, List]: identities_choices["pubkey"].append(gen_pubkey_checksum(lookup["pubkey"])) identities_choices["uid"].append(identity["uid"]) identities_choices["timestamp"].append( - identity["meta"]["timestamp"][:20] + "…" + identity["meta"]["timestamp"][:20] + "…", ) identities = len(identities_choices["uid"]) diff --git a/tests/integration/blockchain/test_verify.py b/tests/integration/blockchain/test_verify.py index 129dc3cb..e56ab114 100644 --- a/tests/integration/blockchain/test_verify.py +++ b/tests/integration/blockchain/test_verify.py @@ -35,7 +35,8 @@ def current(self): @pytest.mark.parametrize( - "from_block, to_block", [(2, 1), (20000, 15000), (0, HEAD_BLOCK + 1), (300000, 0)] + ("from_block", "to_block"), + [(2, 1), (20000, 15000), (0, HEAD_BLOCK + 1), (300000, 0)], ) def test_check_passed_blocks_range(from_block, to_block, capsys, monkeypatch): monkeypatch.setattr(bma.blockchain, "current", current) @@ -56,7 +57,7 @@ def test_check_passed_blocks_range(from_block, to_block, capsys, monkeypatch): @pytest.mark.parametrize( - "from_block, to_block", + ("from_block", "to_block"), [ (G1_INVALID_BLOCK_SIG, G1_INVALID_BLOCK_SIG), (G1_INVALID_BLOCK_SIG - 5, G1_INVALID_BLOCK_SIG + 5), @@ -67,7 +68,8 @@ def test_check_passed_blocks_range(from_block, to_block, capsys, monkeypatch): def test_verify_blocks_signatures(from_block, to_block, monkeypatch): monkeypatch.setattr(bma.blockchain, "current", current) result = CliRunner().invoke( - cli.cli, ["blockchain", "verify", str(from_block), str(to_block)] + cli.cli, + ["blockchain", "verify", str(from_block), str(to_block)], ) assert result.exit_code == SUCCESS_EXIT_STATUS if to_block == 0: @@ -81,7 +83,7 @@ def test_verify_blocks_signatures(from_block, to_block, monkeypatch): @pytest.mark.parametrize( - "from_block, to_block, chunks_from, chunk_from", + ("from_block", "to_block", "chunks_from", "chunk_from"), [ (140, 15150, [140, 5140, 10140, 15140], 140), (140, 15150, [140, 5140, 10140, 15140], 15140), @@ -96,7 +98,7 @@ def test_get_chunk_size(from_block, to_block, chunks_from, chunk_from): assert chunk_size == to_block + 1 - chunk_from -@pytest.mark.parametrize("chunk_size, chunk_from", [(2, 1), (5, 10)]) +@pytest.mark.parametrize(("chunk_size", "chunk_from"), [(2, 1), (5, 10)]) def test_get_chunks(chunk_size, chunk_from): client = client_instance() chunk = verify.get_chunk(client, chunk_size, chunk_from) diff --git a/tests/integration/test_end_to_end.py b/tests/integration/test_end_to_end.py index c4fe22f0..a96bb3fa 100644 --- a/tests/integration/test_end_to_end.py +++ b/tests/integration/test_end_to_end.py @@ -21,14 +21,14 @@ silkaj = ["poetry", "run", "silkaj"] def test_info(): """tests 'silkaj blockchain info' returns a number of members""" - output = check_output(silkaj + ["blockchain", "info"]) + output = check_output([*silkaj, "blockchain", "info"]) assert "Number of members" in output.decode() def test_wot_status(): """tests 'silkaj wot status' returns a number of members""" - output = check_output(silkaj + ["wot", "status", "Matograine"]).decode() + output = check_output([*silkaj, "wot", "status", "Matograine"]).decode() assert "Matograine (CmFKubyq…:CQ5) from block #106433-00000340…" in output assert "received_expire" in output assert "received" in output @@ -39,7 +39,7 @@ def test_wot_status(): def test_wot_lookup(): """tests 'silkaj wot lookup' certification on gtest""" - output = check_output(silkaj + ["--gtest", "wot", "lookup", "elois"]).decode() + output = check_output([*silkaj, "--gtest", "wot", "lookup", "elois"]).decode() assert "D7CYHJXjaH4j7zRdWngUbsURPnSnjsCYtvo6f8dvW3C" in output @@ -47,13 +47,13 @@ def test_money_balance(): """tests 'silkaj money balance' command on gtest""" output = check_output( - silkaj - + [ + [ + *silkaj, "--gtest", "money", "balance", "3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj", - ] + ], ).decode() assert ( "│ Balance of pubkey │ 3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj │" diff --git a/tests/integration/wot/test_membership.py b/tests/integration/wot/test_membership.py index cc317eb2..5a039725 100644 --- a/tests/integration/wot/test_membership.py +++ b/tests/integration/wot/test_membership.py @@ -30,7 +30,7 @@ from tests.patched.blockchain_tools import fake_block_id, patched_get_head_block # Values and patches PUBKEY = "EA7Dsw39ShZg4SpURsrgMaMqrweJPUFPYHwZA8e92e3D" identity_block_id = get_block_id( - "0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855" + "0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", ) identity_uid = "toto" @@ -50,7 +50,7 @@ def patched_choose_identity(pubkey): @pytest.mark.parametrize( - "dry_run, display, confirmation", + ("dry_run", "display", "confirmation"), [ (True, False, False), (False, True, False), diff --git a/tests/patched/blockchain_tools.py b/tests/patched/blockchain_tools.py index 7fb20636..12d90ada 100644 --- a/tests/patched/blockchain_tools.py +++ b/tests/patched/blockchain_tools.py @@ -36,7 +36,8 @@ mocked_block_gtest = { } fake_block_id = BlockID( - 48000, "0000010D30B1284D34123E036B7BE0A449AE9F2B928A77D7D20E3BDEAC7EE14C" + 48000, + "0000010D30B1284D34123E036B7BE0A449AE9F2B928A77D7D20E3BDEAC7EE14C", ) diff --git a/tests/patched/idty_tools.py b/tests/patched/idty_tools.py index a688a608..f13acedb 100644 --- a/tests/patched/idty_tools.py +++ b/tests/patched/idty_tools.py @@ -21,7 +21,7 @@ idty1 = Identity( pubkey="6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o", uid="Claude", block_id=BlockID.from_str( - "597334-002A45E751DCA7535D4F0A082F493E2C8EFF07612683525EB5DA92B6D17C30BD" + "597334-002A45E751DCA7535D4F0A082F493E2C8EFF07612683525EB5DA92B6D17C30BD", ), ) idty1.signature = "kFW2we2K3zx4PZODx0Wf+xdXAJTmYD+yqdyZBsPF7UwqdaCA4N\ @@ -37,7 +37,7 @@ lookup_one = { "uid": "Claude", "meta": { "timestamp": "597334-002A45E751DCA7535D4F0A08\ -2F493E2C8EFF07612683525EB5DA92B6D17C30BD" +2F493E2C8EFF07612683525EB5DA92B6D17C30BD", }, "revoked": False, "revoked_on": None, @@ -62,7 +62,7 @@ lookup_two = { "uid": "Claude", "meta": { "timestamp": "597334-002A45E751DCA7535D4F0A08\ -2F493E2C8EFF07612683525EB5DA92B6D17C30BD" +2F493E2C8EFF07612683525EB5DA92B6D17C30BD", }, "revoked": False, "revoked_on": None, @@ -75,7 +75,7 @@ lookup_two = { "uid": "Claudia", "meta": { "timestamp": "597334-002A45E751DCA7535D4F0A08\ -2F493E2C8EFF07612683525EB5DA92B6D17C30BD" +2F493E2C8EFF07612683525EB5DA92B6D17C30BD", }, "revoked": False, "revoked_on": None, @@ -100,7 +100,7 @@ lookup_three = { "uid": "Claude", "meta": { "timestamp": "597334-002A45E751DCA7535D4F0A08\ -2F493E2C8EFF07612683525EB5DA92B6D17C30BD" +2F493E2C8EFF07612683525EB5DA92B6D17C30BD", }, "revoked": False, "revoked_on": None, @@ -118,7 +118,7 @@ lookup_three = { "uid": "Claude", "meta": { "timestamp": "597334-002A45E751DCA7535D4F0A08\ -2F493E2C8EFF07612683525EB5DA92B6D17C30BD" +2F493E2C8EFF07612683525EB5DA92B6D17C30BD", }, "revoked": False, "revoked_on": None, @@ -138,7 +138,7 @@ idty2 = Identity( pubkey="969qRJs8KhsnkyzqarpL4RKZGMdVKNbZgu8fhsigM7Lj", uid="aa_aa", block_id=BlockID.from_str( - "703902-00002D6BC5E4FC540A4E188C3880A0ACCA06CD77017D26231A515312162B4070" + "703902-00002D6BC5E4FC540A4E188C3880A0ACCA06CD77017D26231A515312162B4070", ), ) idty2.signature = "3RNQcKNI1VMmuCpK7wer8haOA959EQSDIR1v0Ue/7TpTCOmsU2\ diff --git a/tests/patched/money.py b/tests/patched/money.py index 21a100cc..0c2b4998 100644 --- a/tests/patched/money.py +++ b/tests/patched/money.py @@ -58,7 +58,7 @@ def patched_get_sources(pubkey): source="D", origin_id=pubkey, index=a, - ) + ), ) balance += amount_in_current_base(listinput[-1]) a += 1 @@ -74,7 +74,7 @@ def patched_get_sources(pubkey): source="T", origin_id="1F3059ABF35D78DFB5AFFB3DEAB4F76878B04DB6A14757BBD6B600B1C19157E7", index=a, - ) + ), ) balance += amount_in_current_base(listinput[-1]) a += 1 @@ -97,7 +97,7 @@ def patched_get_sources(pubkey): source="T", origin_id="1F3059ABF35D78DFB5AFFB3DEAB4F76878B04DB6A14757BBD6B600B1C19157E7", index=93, - ) + ), ) max_ud = 0 max_tx = 6 @@ -116,7 +116,7 @@ def patched_get_sources(pubkey): source="T", origin_id="1F3059ABF35D78DFB5AFFB3DEAB4F76878B04DB6A14757BBD6B600B1C19157E7", index=93, - ) + ), ) max_ud = 4 max_tx = 20 @@ -128,7 +128,7 @@ def patched_get_sources(pubkey): source="T", origin_id="1F3059ABF35D78DFB5AFFB3DEAB4F76878B04DB6A14757BBD6B600B1C19157E7", index=0, - ) + ), ) max_ud = 0 max_tx = 0 diff --git a/tests/patched/tx.py b/tests/patched/tx.py index 48de4959..4be63591 100644 --- a/tests/patched/tx.py +++ b/tests/patched/tx.py @@ -39,7 +39,7 @@ def patched_gen_confirmation_table( and sum(tx_amounts) <= pubkey_amount ): sys.exit( - "Test error : patched_transaction_confirmation() : Parameters are not coherent" + "Test error : patched_transaction_confirmation() : Parameters are not coherent", ) @@ -64,7 +64,7 @@ def patched_handle_intermediaries_transactions( and key.pubkey() == issuers ): sys.exit( - "Test error : patched_handle_intermediaries_transactions() : Parameters are not coherent" + "Test error : patched_handle_intermediaries_transactions() : Parameters are not coherent", ) @@ -92,5 +92,5 @@ def patched_generate_and_send_transaction( and key.pubkey() == issuers ): sys.exit( - "Test error : patched_generate_and_send_transaction() : Parameters are not coherent" + "Test error : patched_generate_and_send_transaction() : Parameters are not coherent", ) diff --git a/tests/patched/tx_history.py b/tests/patched/tx_history.py index b22b3f6b..55717b3e 100644 --- a/tests/patched/tx_history.py +++ b/tests/patched/tx_history.py @@ -25,7 +25,7 @@ fake_received_tx_hist = [ "blockstampTime": 1535913486, "issuers": ["CvrMiUhAJpNyX5sdAyZqPE6yEFfSsf6j9EpMmeKvMCWW"], "inputs": [ - "7014:0:T:00DFBACFA3434057F6B2DAA8249324C64A658E40BC85CFD40E15FADDD88BACE3:1" + "7014:0:T:00DFBACFA3434057F6B2DAA8249324C64A658E40BC85CFD40E15FADDD88BACE3:1", ], "outputs": [ "100:0:SIG(d88fPFbDdJXJANHH7hedFMaRyGcnVZj9c5cDaE76LRN)", @@ -34,7 +34,7 @@ fake_received_tx_hist = [ "unlocks": ["0:SIG(0)"], "signatures": [ "xz/l3o9GbUclrYDNKiRaVTrBP7cppDmrjDgE2rFNLJsnpu1e/AE2bHyl\ -ftU09NYEDqzCUbehv19oF6zIRVwTDw==" +ftU09NYEDqzCUbehv19oF6zIRVwTDw==", ], "comment": "initialisation", "hash": "D2271075F2308C4092B1F57B3F1BE12AB684FAFCA62BA8EFE9F7F4D7A4D8D69F", @@ -56,7 +56,7 @@ ftU09NYEDqzCUbehv19oF6zIRVwTDw==" "unlocks": ["0:SIG(0)"], "signatures": [ "pYSOTCrl1QbsKrgjgNWnUfD3wJnpbalv9EwjAbZozTbTOSzYoj+UInzK\ -S8/OiSdyVqFVDLdpewTD+FOHRENDAA==" +S8/OiSdyVqFVDLdpewTD+FOHRENDAA==", ], "comment": "", "hash": "F1F2E6D6CF123AB78B98B662FE3AFDD2577B8F6CEBC245660B2E67BC9C2026F6", @@ -75,13 +75,13 @@ fake_sent_tx_hist = [ "blockstampTime": 1613801234, "issuers": ["d88fPFbDdJXJANHH7hedFMaRyGcnVZj9c5cDaE76LRN"], "inputs": [ - "100:0:T:F1F2E6D6CF123AB78B98B662FE3AFDD2577B8F6CEBC245660B2E67BC9C2026F6:0" + "100:0:T:F1F2E6D6CF123AB78B98B662FE3AFDD2577B8F6CEBC245660B2E67BC9C2026F6:0", ], "outputs": ["100:0:SIG(CvrMiUhAJpNyX5sdAyZqPE6yEFfSsf6j9EpMmeKvMCWW)"], "unlocks": ["0:SIG(0)"], "signatures": [ "cMNp7FF5yT/6LJT9CnNzkE08h+APEAYYwdFIROGxUZ9JGqbfPR1NRbcr\ -uq5Fl9BnBcJkuMNJbOwuYV8bPCmICw==" +uq5Fl9BnBcJkuMNJbOwuYV8bPCmICw==", ], "comment": "", "hash": "580715ECD6743590F7A99A6C97E63511BC94B0293CB0037C6A3C96482F8DC7D2", @@ -96,13 +96,13 @@ uq5Fl9BnBcJkuMNJbOwuYV8bPCmICw==" "blockstampTime": 1613801235, "issuers": ["d88fPFbDdJXJANHH7hedFMaRyGcnVZj9c5cDaE76LRN"], "inputs": [ - "100:0:T:D2271075F2308C4092B1F57B3F1BE12AB684FAFCA62BA8EFE9F7F4D7A4D8D69F:0" + "100:0:T:D2271075F2308C4092B1F57B3F1BE12AB684FAFCA62BA8EFE9F7F4D7A4D8D69F:0", ], "outputs": ["100:0:SIG(CmFKubyqbmJWbhyH2eEPVSSs4H4NeXGDfrETzEnRFtPd)"], "unlocks": ["0:SIG(0)"], "signatures": [ "WL3dRX4XUenWlDYYhRmEOUgL5+Tc08LlOJWHNjmTlxqtsdHhGn7MuQ3l\ -K+3Xv7PV6VFEEdc3vlJ52pWCLKN5BA==" +K+3Xv7PV6VFEEdc3vlJ52pWCLKN5BA==", ], "comment": "", "hash": "E874CDAC01D9F291DC1E03F8B0ADB6C19259DE5A11FB73A16318BA1AD59B9EDC", diff --git a/tests/patched/wot.py b/tests/patched/wot.py index 14971ff8..e727937a 100644 --- a/tests/patched/wot.py +++ b/tests/patched/wot.py @@ -29,9 +29,8 @@ pubkey_list = [ # mock is_member def patched_is_member(pubkey): for account in pubkey_list: - if account["pubkey"] == pubkey: - if account["uid"]: - return account + if account["pubkey"] == pubkey and account["uid"]: + return account return False @@ -50,7 +49,7 @@ def patched_wot_requirements_one_pending(pubkey, identity_uid): "userid": "moul-test", "expires_on": 1598624404, "type": "IN", - } + }, ], "membershipPendingExpiresIn": 6311520, "membershipExpiresIn": 2603791, @@ -67,8 +66,8 @@ def patched_wot_requirements_no_pending(pubkey, identity_uid): "pendingMemberships": [], "membershipPendingExpiresIn": 0, "membershipExpiresIn": 3724115, - } - ] + }, + ], } diff --git a/tests/unit/blockchain/test_verify.py b/tests/unit/blockchain/test_verify.py index ee3975b8..83986e9f 100644 --- a/tests/unit/blockchain/test_verify.py +++ b/tests/unit/blockchain/test_verify.py @@ -46,7 +46,7 @@ Nonce: 10099900003511\n" @pytest.mark.parametrize( - "signature, block_raw", + ("signature", "block_raw"), [(invalid_signature, invalid_block_raw), (valid_signature, valid_block_raw)], ) def test_verify_block_signature(signature, block_raw): @@ -61,7 +61,7 @@ def test_verify_block_signature(signature, block_raw): @pytest.mark.parametrize( - "from_block, to_block, invalid_blocks_signatures", + ("from_block", "to_block", "invalid_blocks_signatures"), [(0, 5, []), (100, 500, [53]), (470, 2341, [243, 453])], ) def test_display_result(from_block, to_block, invalid_blocks_signatures, capsys): diff --git a/tests/unit/money/test_history.py b/tests/unit/money/test_history.py index 2dab45c1..2c328815 100644 --- a/tests/unit/money/test_history.py +++ b/tests/unit/money/test_history.py @@ -81,11 +81,11 @@ def test_history_generate_txs_list_and_pubkey_uid_display(monkeypatch): assert "…:" in tx_list[1] # check all lines assert len(txs_list_uids[0][1]) >= min_pubkey_length_with_uid( - SHORT_PUBKEY_LENGTH_WITH_CHECKSUM + SHORT_PUBKEY_LENGTH_WITH_CHECKSUM, ) assert len(txs_list_uids[1][1]) == SHORT_PUBKEY_LENGTH_WITH_CHECKSUM assert len(txs_list_uids[2][1]) >= min_pubkey_length_with_uid( - SHORT_PUBKEY_LENGTH_WITH_CHECKSUM + SHORT_PUBKEY_LENGTH_WITH_CHECKSUM, ) assert len(txs_list_uids[3][1]) == SHORT_PUBKEY_LENGTH_WITH_CHECKSUM @@ -125,14 +125,14 @@ def test_history_generate_txs_list_and_pubkey_uid_display(monkeypatch): assert ":" in tx_list[1] # check all lines assert len(txs_list_uids_full[0][1]) >= min_pubkey_length_with_uid( - MIN_FULL_PUBKEY_LENGTH_WITH_CHECKSUM + MIN_FULL_PUBKEY_LENGTH_WITH_CHECKSUM, ) assert ( len(txs_list_uids_full[1][1]) == MIN_FULL_PUBKEY_LENGTH_WITH_CHECKSUM or len(txs_list_uids_full[1][1]) == MAX_FULL_PUBKEY_LENGTH_WITH_CHECKSUM ) assert len(txs_list_uids_full[2][1]) >= min_pubkey_length_with_uid( - MIN_FULL_PUBKEY_LENGTH_WITH_CHECKSUM + MIN_FULL_PUBKEY_LENGTH_WITH_CHECKSUM, ) assert ( len(txs_list_uids_full[3][1]) == MIN_FULL_PUBKEY_LENGTH_WITH_CHECKSUM @@ -141,7 +141,7 @@ def test_history_generate_txs_list_and_pubkey_uid_display(monkeypatch): @pytest.mark.parametrize( - "tx_addresses, outputs, occurence, return_value", + ("tx_addresses", "outputs", "occurence", "return_value"), [ (None, None, 0, ""), (None, None, 1, "\n"), diff --git a/tests/unit/money/test_tools.py b/tests/unit/money/test_tools.py index 65b1d378..396ec6ef 100644 --- a/tests/unit/money/test_tools.py +++ b/tests/unit/money/test_tools.py @@ -28,7 +28,8 @@ from tests.patched.wot import patched_is_member # display_amount() @pytest.mark.parametrize( - "message, amount, currency_symbol", [("Total", 1000, G1_SYMBOL)] + ("message", "amount", "currency_symbol"), + [("Total", 1000, G1_SYMBOL)], ) def test_display_amount(message, amount, currency_symbol): amount_UD = round(amount / mock_ud_value, 2) @@ -36,7 +37,7 @@ def test_display_amount(message, amount, currency_symbol): [ f"{message} (unit|relative)", f"{str(amount / 100)} {currency_symbol} | {str(amount_UD)} UD {currency_symbol}", - ] + ], ] tx = [] m_tools.display_amount(tx, message, amount, mock_ud_value, currency_symbol) @@ -45,7 +46,7 @@ def test_display_amount(message, amount, currency_symbol): # display_pubkey() @pytest.mark.parametrize( - "message, pubkey, uid", + ("message", "pubkey", "uid"), [ ("From", "CtM5RZHopnSRAAoWNgTWrUhDEmspcCAxn6fuCEWDWudp", "riri"), ("To", "DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw", ""), @@ -115,7 +116,7 @@ A957CD75F781DA8E3E8E966D42A02F59049209533", "blockstampTime": 1607363853, "issuers": ["6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o"], "inputs": [ - "2739:3:D:6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o:664106" + "2739:3:D:6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o:664106", ], "outputs": [ "60:3:SIG(AhRMHUxMPXSeG7qXZrE6qCdjwK9p2bu5Eqei7xAWVEDK)", @@ -124,14 +125,14 @@ A957CD75F781DA8E3E8E966D42A02F59049209533", "unlocks": ["0:SIG(0)"], "signatures": [ "lrmzr/RkecJBOczlmkp3BNCiXejBzTnHdqmNzxQJ\ -yJDIx0UHON4jYkqVKeD77+nrOl8jVtonLt3ZYqd1fhi1Cw==" +yJDIx0UHON4jYkqVKeD77+nrOl8jVtonLt3ZYqd1fhi1Cw==", ], "comment": "DEMAIN DES L_AUBE", "hash": "D5A1A1AAA43FAA242CC2B19763619DA625092BB7FD23397AD362215375A920C8", "time": None, "block_number": None, "received": None, - } + }, ], }, } @@ -140,7 +141,7 @@ yJDIx0UHON4jYkqVKeD77+nrOl8jVtonLt3ZYqd1fhi1Cw==" monkeypatch.setattr(bma_tx, "pending", patched_tx_pending) listinput, balance = m_tools.get_sources( - "AhRMHUxMPXSeG7qXZrE6qCdjwK9p2bu5Eqei7xAWVEDK" + "AhRMHUxMPXSeG7qXZrE6qCdjwK9p2bu5Eqei7xAWVEDK", ) assert len(listinput) == 2 # test SIG() only source is used diff --git a/tests/unit/money/test_transfer.py b/tests/unit/money/test_transfer.py index 878f67e5..3b161fe4 100644 --- a/tests/unit/money/test_transfer.py +++ b/tests/unit/money/test_transfer.py @@ -47,7 +47,7 @@ key_fifi = patched_auth_method("fifi") # truncBase() @pytest.mark.parametrize( - "amount,base,expected", + ("amount", "base", "expected"), [(0, 0, 0), (10, 2, 0), (100, 2, 100), (306, 2, 300), (3060, 3, 3000)], ) def test_truncBase(amount, base, expected): @@ -56,7 +56,14 @@ def test_truncBase(amount, base, expected): # transaction_confirmation() @pytest.mark.parametrize( - "issuer_pubkey, pubkey_balance, tx_amounts, outputAddresses, outputBackChange, comment", + ( + "issuer_pubkey", + "pubkey_balance", + "tx_amounts", + "outputAddresses", + "outputBackChange", + "comment", + ), [ # only one receiver [ @@ -250,7 +257,15 @@ result1 = Transaction( @pytest.mark.parametrize( - "issuers, tx_amounts, listinput_and_amount, outputAddresses, Comment, OutputbackChange, result", + ( + "issuers", + "tx_amounts", + "listinput_and_amount", + "outputAddresses", + "Comment", + "OutputbackChange", + "result", + ), [ # test 1 : with two amounts/outputs and an outputbackchange ( @@ -283,7 +298,7 @@ result1 = Transaction( "Test comment", "BFb5yv8z1fowR6Z8mBXTALy5z7gHfMU976WtXhmRsUMh", result1, - ) + ), ], ) def test_generate_transaction_document( @@ -311,7 +326,7 @@ def test_generate_transaction_document( # get_list_input_for_transaction() @pytest.mark.parametrize( - "pubkey, TXamount, outputs_number, expected", + ("pubkey", "TXamount", "outputs_number", "expected"), [ # no need for interm tx, around 1 source ("CtM5RZHopnSRAAoWNgTWrUhDEmspcCAxn6fuCEWDWudp", 99, 2, (1, 100, False)), @@ -415,7 +430,12 @@ def test_generate_transaction_document( ], ) def test_get_list_input_for_transaction( - pubkey, TXamount, outputs_number, expected, monkeypatch, capsys + pubkey, + TXamount, + outputs_number, + expected, + monkeypatch, + capsys, ): """ expected is [len(listinput), amount, IntermediateTransaction] or "Error" @@ -430,22 +450,33 @@ def test_get_list_input_for_transaction( if isinstance(expected, str): with pytest.raises(SystemExit) as pytest_exit: result = transfer.get_list_input_for_transaction( - pubkey, TXamount, outputs_number + pubkey, + TXamount, + outputs_number, ) assert expected == capsys.readouterr().out assert pytest_exit.type == SystemExit # testing good values else: result = transfer.get_list_input_for_transaction( - pubkey, TXamount, outputs_number + pubkey, + TXamount, + outputs_number, ) assert (len(result[0]), result[1], result[2]) == expected # handle_intermediaries_transactions() @pytest.mark.parametrize( - "key, issuers, tx_amounts, outputAddresses, Comment, \ -OutputbackChange, expected_listinput_amount", + ( + "key", + "issuers", + "tx_amounts", + "outputAddresses", + "Comment", + "OutputbackChange", + "expected_listinput_amount", + ), [ # test 1: with two amounts/outputs and an outputbackchange # no need for intermediary transaction @@ -834,14 +865,21 @@ def test_handle_intermediaries_transactions( patched_generate_and_send_transaction = Mock(return_value=None) monkeypatch.setattr(m_tools, "get_sources", patched_get_sources) monkeypatch.setattr( - transfer, "generate_and_send_transaction", patched_generate_and_send_transaction + transfer, + "generate_and_send_transaction", + patched_generate_and_send_transaction, ) Counter.counter = 0 # testing transfer.handle_intermediaries_transactions( - key, issuers, tx_amounts, outputAddresses, Comment, OutputbackChange + key, + issuers, + tx_amounts, + outputAddresses, + Comment, + OutputbackChange, ) if expected_listinput_amount[2]: @@ -869,8 +907,16 @@ def test_handle_intermediaries_transactions( # test send_transaction() @pytest.mark.parametrize( - "amounts, amountsud, allsources, recipients, comment, \ -outputbackchange, yes, confirmation_answer", + ( + "amounts", + "amountsud", + "allsources", + "recipients", + "comment", + "outputbackchange", + "yes", + "confirmation_answer", + ), [ ( [ @@ -987,7 +1033,9 @@ def test_send_transaction( # patching functions monkeypatch.setattr(auth, "auth_method", patched_auth_method_tx) monkeypatch.setattr( - transfer, "gen_confirmation_table", patched_gen_confirmation_table + transfer, + "gen_confirmation_table", + patched_gen_confirmation_table, ) monkeypatch.setattr( transfer, @@ -1018,7 +1066,13 @@ def test_send_transaction( # create arguments and run cli arguments = construct_args( - amounts, amountsud, allsources, recipients, comment, outputbackchange, yes + amounts, + amountsud, + allsources, + recipients, + comment, + outputbackchange, + yes, ) CliRunner().invoke(cli, args=arguments, input=confirmation_answer) @@ -1058,7 +1112,13 @@ def compute_test_amounts(amounts, mult): # construct click arguments list def construct_args( - amounts, amountsud, allsources, recipients, comment, outputbackchange, yes + amounts, + amountsud, + allsources, + recipients, + comment, + outputbackchange, + yes, ): args_list = ["money", "transfer"] if yes: @@ -1087,7 +1147,15 @@ def construct_args( # generate_and_send_transaction() @pytest.mark.parametrize( - "key, issuers, tx_amounts, listinput_and_amount, outputAddresses, Comment, OutputbackChange", + ( + "key", + "issuers", + "tx_amounts", + "listinput_and_amount", + "outputAddresses", + "Comment", + "OutputbackChange", + ), [ # right tx : 1 amount for 1 receiver ( @@ -1214,7 +1282,7 @@ def construct_args( @pytest.mark.skip( reason="network.send_document mocking fails \ test_revocation_cli{_publish{,_send_errors},_cli_revoke_{,_errors}}\ -which uses this f()" +which uses this f()", ) def test_generate_and_send_transaction( key, @@ -1253,7 +1321,7 @@ def test_generate_and_send_transaction( assert display.find(f" - From: {issuers}") != -1 for tx_amount, outputAddress in zip(tx_amounts, outputAddresses): assert display.find( - f" - To: {outputAddress}\n - Amount: {tx_amount / 100}" + f" - To: {outputAddress}\n - Amount: {tx_amount / 100}", ) transfer.generate_transaction_document.assert_called_once_with( @@ -1270,8 +1338,14 @@ def test_generate_and_send_transaction( # test check_transaction_values() @pytest.mark.parametrize( # issuer_pubkey can be invalid. It is only used for display. - "comment, outputAddresses, outputBackChange, enough_source, \ -issuer_pubkey, expected_outputBackchange", + ( + "comment", + "outputAddresses", + "outputBackChange", + "enough_source", + "issuer_pubkey", + "expected_outputBackchange", + ), [ ( "Test", @@ -1327,7 +1401,11 @@ def test_check_transaction_values( capsys, ): result = transfer.check_transaction_values( - comment, outputAddresses, outputBackChange, enough_source, issuer_pubkey + comment, + outputAddresses, + outputBackChange, + enough_source, + issuer_pubkey, ) assert capsys.readouterr().out == "" assert result == expected_outputBackchange @@ -1336,7 +1414,13 @@ def test_check_transaction_values( # test check_transaction_values() @pytest.mark.parametrize( # issuer_pubkey can be invalid. It is only used for display. - "comment, outputAddresses, outputBackChange, enough_source, issuer_pubkey", + ( + "comment", + "outputAddresses", + "outputBackChange", + "enough_source", + "issuer_pubkey", + ), [ ( "Wrong_Char_é", @@ -1406,11 +1490,20 @@ def test_check_transaction_values( ], ) def test_check_transaction_values_errors( - comment, outputAddresses, outputBackChange, enough_source, issuer_pubkey, capsys + comment, + outputAddresses, + outputBackChange, + enough_source, + issuer_pubkey, + capsys, ): with pytest.raises(SystemExit) as pytest_exit: transfer.check_transaction_values( - comment, outputAddresses, outputBackChange, enough_source, issuer_pubkey + comment, + outputAddresses, + outputBackChange, + enough_source, + issuer_pubkey, ) assert pytest_exit.type == SystemExit display = capsys.readouterr() @@ -1425,14 +1518,14 @@ def test_check_transaction_values_errors( assert display.out.find("Error: bad format for following public key:") != -1 elif enough_source is True: assert ( - display.out.find("pubkey doesn’t have enough money for this transaction.") + display.out.find("pubkey doesn`t have enough money for this transaction.") != -1 ) # test generate_unlocks() @pytest.mark.parametrize( - "listinput, expected", + ("listinput", "expected"), [ ( [ @@ -1464,7 +1557,7 @@ def test_generate_unlocks(listinput, expected): # test generate_output @pytest.mark.parametrize( - "listoutput, unitbase, rest, recipient_address, expected", + ("listoutput", "unitbase", "rest", "recipient_address", "expected"), [ ( [], @@ -1476,7 +1569,7 @@ def test_generate_unlocks(listinput, expected): amount=500, base=0, condition="SIG(2sq4w8yYVDWNxVWZqGWWDriFf5z7dn7iLahDCvEEotuY)", - ) + ), ], ), ( @@ -1508,7 +1601,7 @@ def test_generate_unlocks(listinput, expected): amount=100, base=0, condition="SIG(2sq4w8yYVDWNxVWZqGWWDriFf5z7dn7iLahDCvEEotuY)", - ) + ), ], 0, 500, @@ -1537,7 +1630,7 @@ def test_generate_output(listoutput, unitbase, rest, recipient_address, expected # test max_inputs_number @pytest.mark.parametrize( - "outputs_number, issuers_number, expected", + ("outputs_number", "issuers_number", "expected"), [ (1, 1, 47), (2, 1, 46), diff --git a/tests/unit/money/test_transfer_cli.py b/tests/unit/money/test_transfer_cli.py index 81cb8a6e..780a7b7c 100644 --- a/tests/unit/money/test_transfer_cli.py +++ b/tests/unit/money/test_transfer_cli.py @@ -84,7 +84,7 @@ def test_transaction_amount(monkeypatch): # transaction_amount errors() @pytest.mark.parametrize( - "amounts, UDs_amounts, outputAddresses, expected", + ("amounts", "UDs_amounts", "outputAddresses", "expected"), [ ( None, @@ -107,7 +107,12 @@ def test_transaction_amount(monkeypatch): ], ) def test_transaction_amount_errors( - amounts, UDs_amounts, outputAddresses, expected, capsys, monkeypatch + amounts, + UDs_amounts, + outputAddresses, + expected, + capsys, + monkeypatch, ): # patched functions monkeypatch.setattr(m_tools, "get_ud_value", patched_get_ud_value) @@ -125,42 +130,43 @@ TRANSFER = ["money", "transfer"] def test_tx_passed_amount_cli(): # One option - result = CliRunner().invoke(cli, TRANSFER + ["--amount", "1"]) + result = CliRunner().invoke(cli, [*TRANSFER, "--amount", "1"]) assert "Error: A recipient should be passed\n" in result.output assert result.exit_code == 1 - result = CliRunner().invoke(cli, TRANSFER + ["--amountUD", "1"]) + result = CliRunner().invoke(cli, [*TRANSFER, "--amountUD", "1"]) assert "Error: A recipient should be passed\n" in result.output assert result.exit_code == 1 - result = CliRunner().invoke(cli, TRANSFER + ["--allSources"]) + result = CliRunner().invoke(cli, [*TRANSFER, "--allSources"]) assert "Error: A recipient should be passed\n" in result.output assert result.exit_code == 1 # Multiple options - result = CliRunner().invoke(cli, TRANSFER + ["--amount", 1, "--amountUD", 1]) + result = CliRunner().invoke(cli, [*TRANSFER, "--amount", 1, "--amountUD", 1]) assert "Error: Usage" in result.output assert result.exit_code == 2 - result = CliRunner().invoke(cli, TRANSFER + ["--amount", 1, "--allSources"]) + result = CliRunner().invoke(cli, [*TRANSFER, "--amount", 1, "--allSources"]) assert "Error: Usage" in result.output assert result.exit_code == 2 - result = CliRunner().invoke(cli, TRANSFER + ["--amountUD", 1, "--allSources"]) + result = CliRunner().invoke(cli, [*TRANSFER, "--amountUD", 1, "--allSources"]) assert "Error: Usage" in result.output assert result.exit_code == 2 result = CliRunner().invoke( - cli, TRANSFER + ["--amount", 1, "--amountUD", 1, "--allSources"] + cli, + [*TRANSFER, "--amount", 1, "--amountUD", 1, "--allSources"], ) assert "Error: Usage" in result.output assert result.exit_code == 2 - result = CliRunner().invoke(cli, TRANSFER + ["-r", "A"]) + result = CliRunner().invoke(cli, [*TRANSFER, "-r", "A"]) assert "Error: amount, amountUD or allSources is not set." in result.output assert result.exit_code == FAILURE_EXIT_STATUS - result = CliRunner().invoke(cli, TRANSFER + ["-r", "A", "-r", "B", "--allSources"]) + result = CliRunner().invoke(cli, [*TRANSFER, "-r", "A", "-r", "B", "--allSources"]) assert ( "Error: the --allSources option can only be used with one recipient." in result.output @@ -168,18 +174,20 @@ def test_tx_passed_amount_cli(): assert result.exit_code == FAILURE_EXIT_STATUS result = CliRunner().invoke( - cli, TRANSFER + ["-r", "A", "-a", MINIMAL_ABSOLUTE_TX_AMOUNT - 0.001] + cli, + [*TRANSFER, "-r", "A", "-a", MINIMAL_ABSOLUTE_TX_AMOUNT - 0.001], ) assert "Error: Invalid value for '--amount'" in result.output assert result.exit_code == 2 result = CliRunner().invoke( - cli, TRANSFER + ["-r", "A", "-d", MINIMAL_RELATIVE_TX_AMOUNT - 0.0000001] + cli, + [*TRANSFER, "-r", "A", "-d", MINIMAL_RELATIVE_TX_AMOUNT - 1e-07], ) assert "Error: Invalid value for '--amountUD'" in result.output assert result.exit_code == 2 - result = CliRunner().invoke(cli, TRANSFER + ["-r", "A", "-a", 1, "-a", 2]) + result = CliRunner().invoke(cli, [*TRANSFER, "-r", "A", "-a", 1, "-a", 2]) assert ( "Error: The number of passed recipients is not the same as the passed amounts." in result.output @@ -187,7 +195,8 @@ def test_tx_passed_amount_cli(): assert result.exit_code == FAILURE_EXIT_STATUS result = CliRunner().invoke( - cli, TRANSFER + ["-r", "A", "-r", "B", "-r", "C", "-a", 1, "-a", 2] + cli, + [*TRANSFER, "-r", "A", "-r", "B", "-r", "C", "-a", 1, "-a", 2], ) assert ( "Error: The number of passed recipients is not the same as the passed amounts." @@ -197,22 +206,25 @@ def test_tx_passed_amount_cli(): @pytest.mark.parametrize( - "arguments, auth_method, is_account_filled", + ("arguments", "auth_method", "is_account_filled"), [ ( - TRANSFER + ["--allSources", "-r", "A" * PUBKEY_MIN_LENGTH], + [*TRANSFER, "--allSources", "-r", "A" * PUBKEY_MIN_LENGTH], patched_auth_method_truc, False, ), ( - TRANSFER + ["--allSources", "-r", "A" * PUBKEY_MIN_LENGTH], + [*TRANSFER, "--allSources", "-r", "A" * PUBKEY_MIN_LENGTH], patched_auth_method_riri, True, ), ], ) def test_tx_passed_all_sources_empty( - arguments, auth_method, is_account_filled, monkeypatch + arguments, + auth_method, + is_account_filled, + monkeypatch, ): """test that --allSources on an empty pubkey returns an error""" @@ -221,7 +233,9 @@ def test_tx_passed_all_sources_empty( monkeypatch.setattr(m_tools, "get_sources", patched_get_sources) patched_gen_confirmation_table = Mock() monkeypatch.setattr( - transfer, "gen_confirmation_table", patched_gen_confirmation_table + transfer, + "gen_confirmation_table", + patched_gen_confirmation_table, ) result = CliRunner().invoke(cli, args=arguments) diff --git a/tests/unit/money/test_transfer_file.py b/tests/unit/money/test_transfer_file.py index 84292ac7..95965a37 100644 --- a/tests/unit/money/test_transfer_file.py +++ b/tests/unit/money/test_transfer_file.py @@ -26,7 +26,7 @@ FILE_PATH = "recipients.txt" @pytest.mark.parametrize( - "file_content, amounts_exp, recipients_exp", + ("file_content", "amounts_exp", "recipients_exp"), [ ( "ABSOLUTE\n10 pubkey1\n20 pubkey2", @@ -41,7 +41,10 @@ FILE_PATH = "recipients.txt" ], ) def test_parse_file_containing_amounts_recipients( - file_content, amounts_exp, recipients_exp, monkeypatch + file_content, + amounts_exp, + recipients_exp, + monkeypatch, ): monkeypatch.setattr(tools, "get_ud_value", patched_get_ud_value) @@ -62,7 +65,7 @@ SPEC_ERR = "No amounts or recipients specified" @pytest.mark.parametrize( - "file_content, error", + ("file_content", "error"), [ ("ABSOLUTE\n10 pubkey1\n20", SYNTAX_ERR), ("#RELATIVE\n10 pubkey1\n20 pubkey2", HEADER_ERR), diff --git a/tests/unit/test_auth.py b/tests/unit/test_auth.py index 44edb33d..74b1e532 100644 --- a/tests/unit/test_auth.py +++ b/tests/unit/test_auth.py @@ -27,7 +27,7 @@ from tests.patched.auth import ( # test auth_method @pytest.mark.parametrize( - "seed, file, wif, auth_method_called", + ("seed", "file", "wif", "auth_method_called"), [ (True, False, False, "call_auth_by_seed"), (False, True, False, "call_auth_by_auth_file"), @@ -41,7 +41,8 @@ def test_auth_method(seed, file, wif, auth_method_called, monkeypatch): monkeypatch.setattr(auth, "auth_by_auth_file", patched_auth_by_auth_file) monkeypatch.setattr(auth, "auth_by_scrypt", patched_auth_by_scrypt) ctx = click.Context( - click.Command(""), obj={"AUTH_SEED": seed, "AUTH_FILE": file, "AUTH_WIF": wif} + click.Command(""), + obj={"AUTH_SEED": seed, "AUTH_FILE": file, "AUTH_WIF": wif}, ) with ctx: assert auth_method_called == auth.auth_method() diff --git a/tests/unit/test_checksum.py b/tests/unit/test_checksum.py index 4dc6cde2..8652e85a 100644 --- a/tests/unit/test_checksum.py +++ b/tests/unit/test_checksum.py @@ -28,7 +28,7 @@ pubkey_seedhex_authfile = ( @pytest.mark.parametrize( - "command, excepted_output", + ("command", "excepted_output"), [ (["checksum", pubkey_checksum], "The checksum is valid"), (["checksum", f"{pubkey}:vAK"], "The checksum is invalid"), diff --git a/tests/unit/test_g1_monetary_license.py b/tests/unit/test_g1_monetary_license.py index 767716d6..b7c28d26 100644 --- a/tests/unit/test_g1_monetary_license.py +++ b/tests/unit/test_g1_monetary_license.py @@ -30,7 +30,7 @@ def test_license_approval_g1_test(capsys): # Approve is not tested @pytest.mark.parametrize( - "display, approve", + ("display", "approve"), [ (True, True), (True, False), @@ -50,7 +50,7 @@ def test_license_approval_g1(mock_display_license, mock_confirm, display, approv @pytest.mark.parametrize( - "language, license_sample", + ("language", "license_sample"), [ ("en", "**Currency licensing"), ("", "**Currency licensing"), diff --git a/tests/unit/test_network.py b/tests/unit/test_network.py index 8142975b..531ff3f6 100644 --- a/tests/unit/test_network.py +++ b/tests/unit/test_network.py @@ -30,7 +30,7 @@ IPV6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334" @pytest.mark.parametrize( - "endpoint, host, ipv4, ipv6, port, path", + ("endpoint", "host", "ipv4", "ipv6", "port", "path"), [ ("127.0.0.1", "", "127.0.0.1", None, 443, None), ("127.0.0.1:80", "", "127.0.0.1", None, 80, None), @@ -56,7 +56,7 @@ def test_determine_endpoint_custom(endpoint, host, ipv4, ipv6, port, path): @pytest.mark.parametrize( - "gtest, endpoint", + ("gtest", "endpoint"), [ (True, constants.G1_TEST_DEFAULT_ENDPOINT), (False, constants.G1_DEFAULT_ENDPOINT), diff --git a/tests/unit/test_public_key.py b/tests/unit/test_public_key.py index 508f8ca4..0dfeb236 100644 --- a/tests/unit/test_public_key.py +++ b/tests/unit/test_public_key.py @@ -21,7 +21,7 @@ from silkaj.constants import SHORT_PUBKEY_SIZE # test gen_checksum @pytest.mark.parametrize( - "pubkey, checksum", + ("pubkey", "checksum"), [ ("J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX", "KAv"), ], @@ -32,7 +32,7 @@ def test_gen_checksum(pubkey, checksum): # test validate_checksum @pytest.mark.parametrize( - "pubkey, checksum, expected", + ("pubkey", "checksum", "expected"), [ ("J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX", "KAv", None), ( @@ -56,7 +56,7 @@ def test_validate_checksum(pubkey, checksum, expected, capsys): # test check_pubkey_format @pytest.mark.parametrize( - "pubkey, display_error, expected", + ("pubkey", "display_error", "expected"), [ ("J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX:KAv", True, True), ("J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX", True, False), @@ -76,7 +76,7 @@ def test_check_pubkey_format(pubkey, display_error, expected, capsys): # test is_pubkey_and_check @pytest.mark.parametrize( - "uid_pubkey, expected", + ("uid_pubkey", "expected"), [ ( "J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX:KAv", @@ -95,7 +95,7 @@ def test_is_pubkey_and_check(uid_pubkey, expected): # test is_pubkey_and_check errors @pytest.mark.parametrize( - "uid_pubkey, expected", + ("uid_pubkey", "expected"), [ ( "J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX:KA", @@ -118,7 +118,7 @@ def test_is_pubkey_and_check_errors(uid_pubkey, expected, capsys): # gen_pubkey_checksum @pytest.mark.parametrize( - "pubkey, checksum", + ("pubkey", "checksum"), [ ("J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX", "KAv"), ], @@ -130,5 +130,7 @@ def test_gen_pubkey_checksum(pubkey, checksum): == public_key.gen_pubkey_checksum(pubkey, short=True) ) assert f"{pubkey[:14]}…:{checksum}" == public_key.gen_pubkey_checksum( - pubkey, short=True, length=14 + pubkey, + short=True, + length=14, ) diff --git a/tests/unit/test_tui.py b/tests/unit/test_tui.py index c6fceb06..097c5686 100644 --- a/tests/unit/test_tui.py +++ b/tests/unit/test_tui.py @@ -36,7 +36,7 @@ def test_create_table(): @pytest.mark.parametrize( - "rows, header, expected", + ("rows", "header", "expected"), [ ( [ @@ -92,14 +92,14 @@ def test_fill_rows(rows, header, expected): @pytest.mark.parametrize( - "dict_, expected", + ("dict_", "expected"), [ ( OrderedDict( [ ("one", ["three", "four", "rock"]), ("two", ["o'clock", "o'clock", "rock around the clock"]), - ] + ], ), "│───────│───────────────────────│\n\ │ one │ two │\n\ @@ -120,7 +120,7 @@ def test_fill_from_dict(dict_, expected): @pytest.mark.parametrize( - "dict_list, expected", + ("dict_list", "expected"), [ ( ( diff --git a/tests/unit/wot/test_idty_tools.py b/tests/unit/wot/test_idty_tools.py index 932cdd3a..5da1478d 100644 --- a/tests/unit/wot/test_idty_tools.py +++ b/tests/unit/wot/test_idty_tools.py @@ -41,7 +41,7 @@ id_moul_test_1 = Identity( pubkey="5B8iMAzq1dNmFe3ZxFTBQkqhq4fsztg1gZvxHXCk1XYH", uid="moul-test", block_id=BlockID.from_str( - "167750-0000A51FF952B76AAA594A46CA0C8156A56988D2B2B57BE18ECB4F3CFC25CEC2" + "167750-0000A51FF952B76AAA594A46CA0C8156A56988D2B2B57BE18ECB4F3CFC25CEC2", ), ) id_moul_test_1.signature = "/15YBc4JDPvKD4c8nWD6C0XN0krrS32uDRSH6rJvM\ @@ -52,7 +52,7 @@ id_elois_test = Identity( pubkey="D7CYHJXjaH4j7zRdWngUbsURPnSnjsCYtvo6f8dvW3C", uid="elois", block_id=BlockID.from_str( - "0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855" + "0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", ), ) id_elois_test.signature = "HFmZy01XSXSSsqRWYKR+nIsaReBruJUqYHqJh3EtdR\ @@ -64,7 +64,7 @@ id_moul_test_3 = Identity( pubkey="2M3Et298TDYXDcsixp82iEc4ijzuiyQtsiQac2QjCRgA", uid="moul-test", block_id=BlockID.from_str( - "287573-00003674E9A2B5127327542CFA36BCB95D05E8EBD8AAF9C684B19EB7502161D4" + "287573-00003674E9A2B5127327542CFA36BCB95D05E8EBD8AAF9C684B19EB7502161D4", ), ) id_moul_test_3.signature = "BB1Ete898yN/ZwQn4H7o0gsS1JD05zZBSd7qdU2Am\ @@ -88,7 +88,7 @@ id_claudius_maximus = Identity( pubkey="6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o", uid="Claudius Maximus", block_id=BlockID.from_str( - "7334-002A45E751DCA7535D4F0A082F493E2C8EFF07612683525EB5DA92B6D17C30BD" + "7334-002A45E751DCA7535D4F0A082F493E2C8EFF07612683525EB5DA92B6D17C30BD", ), ) id_claudius_maximus.signature = ( @@ -125,7 +125,7 @@ def test_display_alternate_ids(): @pytest.mark.parametrize( - "lookups_pubkey, lookups_uid, currency, expected", + ("lookups_pubkey", "lookups_uid", "currency", "expected"), [ ( [ @@ -136,7 +136,7 @@ def test_display_alternate_ids(): "uid": "moul-test", "meta": { "timestamp": "167750-0000A51FF952B76A\ -AA594A46CA0C8156A56988D2B2B57BE18ECB4F3CFC25CEC2" +AA594A46CA0C8156A56988D2B2B57BE18ECB4F3CFC25CEC2", }, "revoked": False, "revoked_on": None, @@ -144,7 +144,7 @@ AA594A46CA0C8156A56988D2B2B57BE18ECB4F3CFC25CEC2" "self": "/15YBc4JDPvKD4c8nWD6C0XN0krrS32u\ DRSH6rJvMFih/H5nPc8oiCgL27bA7P3NPnp+oCqbS12QygQRnhoDDQ==", "others": [], - } + }, ], "signed": [], }, @@ -155,7 +155,7 @@ DRSH6rJvMFih/H5nPc8oiCgL27bA7P3NPnp+oCqbS12QygQRnhoDDQ==", "uid": "elois", "meta": { "timestamp": "0-E3B0C44298FC1C149AFBF\ -4C8996FB92427AE41E4649B934CA495991B7852B855" +4C8996FB92427AE41E4649B934CA495991B7852B855", }, "revoked": True, "revoked_on": 1540589179, @@ -163,7 +163,7 @@ DRSH6rJvMFih/H5nPc8oiCgL27bA7P3NPnp+oCqbS12QygQRnhoDDQ==", "self": "HFmZy01XSXSSsqRWYKR+nIsaReBruJUq\ YHqJh3EtdRkHV3i30S2lM32pM2w4GHYXNIiOf4+NXzcmuEQVkewBAA==", "others": [], - } + }, ], "signed": [], }, @@ -176,7 +176,7 @@ YHqJh3EtdRkHV3i30S2lM32pM2w4GHYXNIiOf4+NXzcmuEQVkewBAA==", "uid": "moul-test", "meta": { "timestamp": "167750-0000A51FF952B76A\ -AA594A46CA0C8156A56988D2B2B57BE18ECB4F3CFC25CEC2" +AA594A46CA0C8156A56988D2B2B57BE18ECB4F3CFC25CEC2", }, "revoked": False, "revoked_on": None, @@ -184,7 +184,7 @@ AA594A46CA0C8156A56988D2B2B57BE18ECB4F3CFC25CEC2" "self": "/15YBc4JDPvKD4c8nWD6C0XN0krrS32u\ DRSH6rJvMFih/H5nPc8oiCgL27bA7P3NPnp+oCqbS12QygQRnhoDDQ==", "others": [], - } + }, ], "signed": [], }, @@ -195,7 +195,7 @@ DRSH6rJvMFih/H5nPc8oiCgL27bA7P3NPnp+oCqbS12QygQRnhoDDQ==", "uid": "moul-test", "meta": { "timestamp": "287573-00003674E9A2B512\ -7327542CFA36BCB95D05E8EBD8AAF9C684B19EB7502161D4" +7327542CFA36BCB95D05E8EBD8AAF9C684B19EB7502161D4", }, "revoked": True, "revoked_on": 1544923049, @@ -204,7 +204,7 @@ LpQcpx9FZJNXIt79Q/zRPpi9X1hNUPKV4myMxHBSVI6YbPB+gBw/Bb+n3kaIuRAg==", "self": "BB1Ete898yN/ZwQn4H7o0gsS1JD05zZB\ Sd7qdU2AmSSZLtjG199fN0Z5jKjQi7S2IVvrH0G5cft74sufVS3+Cw==", "others": [], - } + }, ], "signed": [], }, @@ -216,13 +216,14 @@ Sd7qdU2AmSSZLtjG199fN0Z5jKjQi7S2IVvrH0G5cft74sufVS3+Cw==", ) def test_merge_ids_lists(lookups_pubkey, lookups_uid, currency, expected): for element, expect in zip( - idty_tools.merge_ids_lists(lookups_pubkey, lookups_uid, currency), expected + idty_tools.merge_ids_lists(lookups_pubkey, lookups_uid, currency), + expected, ): assert element.signed_raw() == expect.signed_raw() @pytest.mark.parametrize( - "lookups, currency, expected", + ("lookups", "currency", "expected"), [ ( [ @@ -233,7 +234,7 @@ def test_merge_ids_lists(lookups_pubkey, lookups_uid, currency, expected): "uid": "moul-test", "meta": { "timestamp": "167750-0000A51FF952B76A\ -AA594A46CA0C8156A56988D2B2B57BE18ECB4F3CFC25CEC2" +AA594A46CA0C8156A56988D2B2B57BE18ECB4F3CFC25CEC2", }, "revoked": False, "revoked_on": None, @@ -241,7 +242,7 @@ AA594A46CA0C8156A56988D2B2B57BE18ECB4F3CFC25CEC2" "self": "/15YBc4JDPvKD4c8nWD6C0XN0krrS32u\ DRSH6rJvMFih/H5nPc8oiCgL27bA7P3NPnp+oCqbS12QygQRnhoDDQ==", "others": [], - } + }, ], "signed": [], }, @@ -252,7 +253,7 @@ DRSH6rJvMFih/H5nPc8oiCgL27bA7P3NPnp+oCqbS12QygQRnhoDDQ==", "uid": "elois", "meta": { "timestamp": "0-E3B0C44298FC1C149AFBF\ -4C8996FB92427AE41E4649B934CA495991B7852B855" +4C8996FB92427AE41E4649B934CA495991B7852B855", }, "revoked": True, "revoked_on": 1540589179, @@ -260,7 +261,7 @@ DRSH6rJvMFih/H5nPc8oiCgL27bA7P3NPnp+oCqbS12QygQRnhoDDQ==", "self": "HFmZy01XSXSSsqRWYKR+nIsaReBruJUq\ YHqJh3EtdRkHV3i30S2lM32pM2w4GHYXNIiOf4+NXzcmuEQVkewBAA==", "others": [], - } + }, ], "signed": [], }, @@ -272,7 +273,8 @@ YHqJh3EtdRkHV3i30S2lM32pM2w4GHYXNIiOf4+NXzcmuEQVkewBAA==", ) def test_ids_list_from_lookups(lookups, currency, expected): for element, expect in zip( - idty_tools.ids_list_from_lookups(lookups, currency), expected + idty_tools.ids_list_from_lookups(lookups, currency), + expected, ): assert element.signed_raw() == expect.signed_raw() @@ -295,7 +297,7 @@ def test_display_identity(idty, monkeypatch, capsys): @pytest.mark.parametrize( - "idty, lookup_pk, lookup_uid, expected, expect_bool", + ("idty", "lookup_pk", "lookup_uid", "expected", "expect_bool"), [ # normal case : 1 same lookup on pubkey and uid ( @@ -362,14 +364,20 @@ def test_display_identity(idty, monkeypatch, capsys): None, [ f"Identity document does not match any valid identity.\n\ -uid: {idty1.uid}\npubkey: {gen_pubkey_checksum(idty1.pubkey)}" +uid: {idty1.uid}\npubkey: {gen_pubkey_checksum(idty1.pubkey)}", ], False, ), ], ) def test_check_many_identities( - idty, lookup_pk, lookup_uid, expected, expect_bool, monkeypatch, capsys + idty, + lookup_pk, + lookup_uid, + expected, + expect_bool, + monkeypatch, + capsys, ): # Patch BMA lookup so it returns different lookups if we request a pk or a uid def patched_bma_lookup(whatever_node, lookup): @@ -394,7 +402,7 @@ def test_check_many_identities( # identity does not exist if expected == [ f"Identity document does not match any valid identity.\ -\nuid: {idty.uid}\npubkey: {gen_pubkey_checksum(idty.pubkey)}" +\nuid: {idty.uid}\npubkey: {gen_pubkey_checksum(idty.pubkey)}", ]: with pytest.raises(SystemExit) as pytest_exit: result = idty_tools.check_many_identities(idty) diff --git a/tests/unit/wot/test_membership.py b/tests/unit/wot/test_membership.py index aa789e20..53fe850b 100644 --- a/tests/unit/wot/test_membership.py +++ b/tests/unit/wot/test_membership.py @@ -39,7 +39,7 @@ from tests.patched.wot import ( # Values and patches PUBKEY = "EA7Dsw39ShZg4SpURsrgMaMqrweJPUFPYHwZA8e92e3D" identity_block_id = get_block_id( - "0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855" + "0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", ) identity_uid = "toto" @@ -74,7 +74,7 @@ def test_display_confirmation_table(patched_wot_requirements, monkeypatch, capsy [ "Expiration date of current membership", pendulum.now().add(seconds=membership_expires).diff_for_humans(), - ] + ], ) if pending_memberships: @@ -82,13 +82,13 @@ def test_display_confirmation_table(patched_wot_requirements, monkeypatch, capsy [ "Number of pending membership(s) in the mempool", len(pending_memberships), - ] + ], ) table.append( [ "Pending membership documents will expire", pendulum.now().add(seconds=pending_expires).diff_for_humans(), - ] + ], ) table.append(["User Identifier (UID)", identity_uid]) @@ -109,14 +109,14 @@ def test_display_confirmation_table(patched_wot_requirements, monkeypatch, capsy [ "Expiration date of new membership", pendulum.now().add(seconds=params["msValidity"]).diff_for_humans(), - ] + ], ) table.append( [ "Expiration date of new membership from the mempool", pendulum.now().add(seconds=params["msPeriod"]).diff_for_humans(), - ] + ], ) display_table = tui.Table() diff --git a/tests/unit/wot/test_revocation.py b/tests/unit/wot/test_revocation.py index 23978199..aa69e255 100644 --- a/tests/unit/wot/test_revocation.py +++ b/tests/unit/wot/test_revocation.py @@ -141,7 +141,7 @@ def patched_send_bma_revoke_error(wot_useless, rev_doc_useless): # test cli dry-run @pytest.mark.parametrize( - "subcommand, expected_warn", + ("subcommand", "expected_warn"), [ ( "create", @@ -170,7 +170,9 @@ def test_revocation_cli_dry_run(subcommand, expected_warn, monkeypatch): monkeypatch.setattr(w_tools, "choose_identity", patched_choose_identity) monkeypatch.setattr(bma.blockchain, "block", patch_get_id_block) monkeypatch.setattr( - idty_tools, "check_many_identities", patch_check_many_identities + idty_tools, + "check_many_identities", + patch_check_many_identities, ) print("subcommand: ", subcommand) # debug @@ -196,7 +198,7 @@ def test_revocation_cli_dry_run(subcommand, expected_warn, monkeypatch): # test cli create @pytest.mark.parametrize( - "display, dry_run, file, user_input, expected", + ("display", "dry_run", "file", "user_input", "expected"), [ ( False, @@ -316,7 +318,7 @@ def test_revocation_cli_save(display, dry_run, file, user_input, expected, monke # test cli verify @pytest.mark.parametrize( - "display, dry_run, doc, lookup, file, expected, not_expected", + ("display", "dry_run", "doc", "lookup", "file", "expected", "not_expected"), [ ( False, @@ -404,7 +406,14 @@ def test_revocation_cli_save(display, dry_run, file, user_input, expected, monke ], ) def test_revocation_cli_verify( - display, dry_run, doc, lookup, file, expected, not_expected, monkeypatch + display, + dry_run, + doc, + lookup, + file, + expected, + not_expected, + monkeypatch, ): def patched_lookup(node, id_pubkey): return lookup @@ -435,7 +444,7 @@ def test_revocation_cli_verify( # test cli publish @pytest.mark.parametrize( - "display, dry_run, doc, lookup, file, user_input, expected", + ("display", "dry_run", "doc", "lookup", "file", "user_input", "expected"), [ ( False, @@ -659,7 +668,14 @@ def test_revocation_cli_verify( ], ) def test_revocation_cli_publish( - display, dry_run, doc, lookup, file, user_input, expected, monkeypatch + display, + dry_run, + doc, + lookup, + file, + user_input, + expected, + monkeypatch, ): def patched_lookup(node, id_pubkey): if not lookup: @@ -695,7 +711,8 @@ def test_revocation_cli_publish( result = runner.invoke(cli, args=command, input=user_input) if user_input == "yes\n" and not dry_run: patched_send_bma_revoke.assert_called_once_with( - client_instance(), doc.signed_raw() + client_instance(), + doc.signed_raw(), ) elif dry_run or user_input == "no\n": patched_send_bma_revoke.assert_not_called() @@ -705,7 +722,7 @@ def test_revocation_cli_publish( # test cli publish send errors @pytest.mark.parametrize( - "display, file, user_input, expected", + ("display", "file", "user_input", "expected"), [ ( False, @@ -752,7 +769,11 @@ def test_revocation_cli_publish( ], ) def test_revocation_cli_publish_send_errors( - display, file, user_input, expected, monkeypatch + display, + file, + user_input, + expected, + monkeypatch, ): def patched_lookup(node, id_pubkey): return lookup_one @@ -783,7 +804,7 @@ def test_revocation_cli_publish_send_errors( # test cli revoke @pytest.mark.parametrize( - "display, dry_run, user_input, doc, expected", + ("display", "dry_run", "user_input", "doc", "expected"), [ ( False, @@ -841,7 +862,12 @@ def test_revocation_cli_publish_send_errors( ], ) def test_revocation_cli_revoke( - display, dry_run, user_input, doc, expected, monkeypatch + display, + dry_run, + user_input, + doc, + expected, + monkeypatch, ): monkeypatch.setattr(auth, "auth_method", patched_auth_method_Claude) monkeypatch.setattr(bc_tools, "get_head_block", patched_get_head_block_gtest) @@ -865,7 +891,7 @@ def test_revocation_cli_revoke( # test cli revoke errors @pytest.mark.parametrize( - "display, user_input, doc, expected", + ("display", "user_input", "doc", "expected"), [ ( False, @@ -907,7 +933,7 @@ def test_revocation_cli_revoke_errors(display, user_input, doc, expected, monkey # test create_revocation_doc -@pytest.mark.parametrize("idty, lookup", [(idty1, lookup_one)]) +@pytest.mark.parametrize(("idty", "lookup"), [(idty1, lookup_one)]) def test_create_revocation_doc(idty, lookup): test = revocation.create_revocation_doc( lookup["results"][0]["uids"][0], @@ -924,7 +950,7 @@ def test_create_revocation_doc(idty, lookup): # test save_doc @pytest.mark.parametrize( - "path, rev_1, rev_2, pubkey", + ("path", "rev_1", "rev_2", "pubkey"), [ ( "./test_doc.txt", @@ -972,7 +998,7 @@ for following public key: {gen_pubkey_checksum(pubkey)}" # test verify_document @pytest.mark.parametrize( - "doc, lookup", + ("doc", "lookup"), [ (REV_DOC, lookup_one), (REV_DOC, lookup_two), @@ -1001,7 +1027,7 @@ def test_verify_document(doc, lookup, capsys, monkeypatch): # test verify_document: no matching identity @pytest.mark.parametrize( - "doc, lookup", + ("doc", "lookup"), [ (REV_2, lookup_one), (REV_2, lookup_two), @@ -1036,7 +1062,7 @@ def test_verify_document_missing_id(doc, lookup, capsys, monkeypatch): display = capsys.readouterr().out if not lookup: assert "Revocation document does not match any valid identity." in str( - pytest_exit.value.code + pytest_exit.value.code, ) else: assert pytest_exit.value.code == FAILURE_EXIT_STATUS @@ -1048,7 +1074,7 @@ def test_verify_document_missing_id(doc, lookup, capsys, monkeypatch): # test verify_document : format and sign errors @pytest.mark.parametrize( - "doc, currency", + ("doc", "currency"), [ (REV_DOC_FALSE, REV_DOC_FALSE.currency), (REV_2_FALSE, REV_2_FALSE.currency), diff --git a/tests/unit/wot/test_tools.py b/tests/unit/wot/test_tools.py index 85eaa8dd..e50f4090 100644 --- a/tests/unit/wot/test_tools.py +++ b/tests/unit/wot/test_tools.py @@ -55,7 +55,7 @@ def patched_lookup_one(pubkey_uid): "pubkey": pubkey_titi_tata, "uids": [titi], "signed": [], - } + }, ] @@ -65,7 +65,7 @@ def patched_lookup_two(pubkey_uid): "pubkey": pubkey_titi_tata, "uids": [titi, tata], "signed": [], - } + }, ] @@ -131,7 +131,7 @@ def patched_prompt_tutu(message): @pytest.mark.parametrize( - "selected_uid, pubkey, patched_prompt, patched_lookup", + ("selected_uid", "pubkey", "patched_prompt", "patched_lookup"), [ ("titi", pubkey_titi_tata, patched_prompt_titi, patched_lookup_one), ("titi", pubkey_titi_tata_checksum, patched_prompt_titi, patched_lookup_one), @@ -142,7 +142,12 @@ def patched_prompt_tutu(message): ], ) def test_choose_identity( - selected_uid, pubkey, patched_prompt, patched_lookup, capsys, monkeypatch + selected_uid, + pubkey, + patched_prompt, + patched_lookup, + capsys, + monkeypatch, ): monkeypatch.setattr(w_tools, "wot_lookup", patched_lookup) monkeypatch.setattr(click, "prompt", patched_prompt) -- GitLab