From ccb655e711f3f6966e80af834ddd6856d6539aca Mon Sep 17 00:00:00 2001 From: matograine <tom.ngr@zaclys.net> Date: Fri, 11 Dec 2020 17:51:34 +0100 Subject: [PATCH] [enh] #203 use texttable in tx.py * modify related test so it does not fail --- silkaj/tx.py | 12 ++++++++---- tests/test_unit_tx.py | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/silkaj/tx.py b/silkaj/tx.py index edbe3b16..2a492b60 100644 --- a/silkaj/tx.py +++ b/silkaj/tx.py @@ -18,7 +18,6 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. from re import compile, search import math from asyncio import sleep -from tabulate import tabulate from click import command, option, FloatRange from silkaj import cli_tools @@ -129,10 +128,15 @@ async def send_transaction( issuer_pubkey, ) + # create display table + table = tui.create_table() + table.set_header_align(["l", "l"]) + table.set_cols_align(["l", "l"]) + if ( yes or input( - tabulate( + table.add_rows( await transaction_confirmation( issuer_pubkey, pubkey_amount[0], @@ -141,8 +145,8 @@ async def send_transaction( outputbackchange, comment, ), - tablefmt="fancy_grid", - ) + header=False, + ).draw() + "\nDo you confirm sending this transaction? [yes/no]: " ) == "yes" diff --git a/tests/test_unit_tx.py b/tests/test_unit_tx.py index bcab87b3..3ed089dd 100644 --- a/tests/test_unit_tx.py +++ b/tests/test_unit_tx.py @@ -939,7 +939,9 @@ def test_send_transaction( return args_list # mocking functions - patched_transaction_confirmation = AsyncMock(return_value=None) + patched_transaction_confirmation = AsyncMock( + return_value=[["fake", "list"], ["one", "two"]] + ) # return fake values for confirmation table patched_handle_intermediaries_transactions = AsyncMock(return_value=None) # patching functions -- GitLab