diff --git a/silkaj/money.py b/silkaj/money.py index a4596771dba4bff0104c42c63f7bba5720dfc9cf..b63e46c009a56c21158babd0a9c7d015c02a7bdf 100644 --- a/silkaj/money.py +++ b/silkaj/money.py @@ -16,9 +16,9 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ from click import command, argument, pass_context, echo -from tabulate import tabulate from silkaj import wot_tools as wt +from silkaj import tui from silkaj.network_tools import ClientInstance from silkaj.blockchain_tools import HeadBlock from silkaj.tools import CurrencySymbol, message_exit, coroutine @@ -28,7 +28,6 @@ from silkaj.crypto_tools import ( check_pubkey_format, validate_checksum, ) -from silkaj.tui import display_amount, display_pubkey_and_checksum from duniterpy.api.bma import tx, blockchain from duniterpy.documents.transaction import InputSource @@ -54,7 +53,7 @@ async def cmd_amount(ctx, pubkeys): print(f"ERROR: pubkey {inputPubkey} has a wrong format") elif pubkey in pubkeys_list: message_exit( - f"ERROR: pubkey {display_pubkey_and_checksum(pubkey)} was specified many times" + f"ERROR: pubkey {tui.display_pubkey_and_checksum(pubkey)} was specified many times" ) pubkeys_list.append(pubkey) if wrong_pubkeys: @@ -90,7 +89,7 @@ async def show_amount_from_pubkey(label, inputs_balance): # if `pubkey` is a pubkey, get pubkey:checksum and uid if label != "Total": member = await wt.is_member(label) - label = display_pubkey_and_checksum(label) + label = tui.display_pubkey_and_checksum(label) # display balance table display = list() display.append(["Balance of pubkey", label]) @@ -99,22 +98,25 @@ async def show_amount_from_pubkey(label, inputs_balance): display.append(["User identifier", member["uid"]]) if totalAmountInput - balance != 0: - display_amount(display, "Blockchain", balance, ud_value, currency_symbol) - display_amount( + tui.display_amount(display, "Blockchain", balance, ud_value, currency_symbol) + tui.display_amount( display, "Pending transaction", (totalAmountInput - balance), ud_value, currency_symbol, ) - display_amount(display, "Total amount", totalAmountInput, ud_value, currency_symbol) + tui.display_amount( + display, "Total amount", totalAmountInput, ud_value, currency_symbol + ) display.append( [ "Total relative to M/N", "{0} x M/N".format(round(totalAmountInput / average, 2)), ] ) - echo(tabulate(display, tablefmt="fancy_grid")) + table = tui.create_table() + echo(tui.vert_table(table, display)) async def get_average(): diff --git a/tests/test_end_to_end.py b/tests/test_end_to_end.py index 51ccb213d011ba2847422ef80675d8164461cbfd..e54e94798ec56baf527610dd4156e8a9c06f325e 100644 --- a/tests/test_end_to_end.py +++ b/tests/test_end_to_end.py @@ -51,8 +51,9 @@ def test_balance(): output = check_output( silkaj + ["--gtest", "balance", "3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj"] ).decode() + print(output) # debug assert ( - "│ Balance of pubkey │ 3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj:EyF │" + "│ Balance of pubkey │ 3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj: │" in output ) assert "│ Total amount (unit|relative) │" in output