From 3063ef4d4445674e0a315107c02621d09a4a217b Mon Sep 17 00:00:00 2001 From: matograine <matograine@zaclys.net> Date: Mon, 20 Jun 2022 22:20:26 +0200 Subject: [PATCH] [mod] #203 reformat tx_history: rename generate_table to generate_txs_list --- silkaj/tx_history.py | 16 ++++++++-------- tests/test_tx_history.py | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/silkaj/tx_history.py b/silkaj/tx_history.py index 4f4950ac..278ac5c4 100644 --- a/silkaj/tx_history.py +++ b/silkaj/tx_history.py @@ -50,7 +50,7 @@ def transaction_history(pubkey: str, uids: bool, full_pubkey: bool) -> None: get_transactions_history(client, pubkey, received_txs, sent_txs) remove_duplicate_txs(received_txs, sent_txs) - txs_list = generate_table( + txs_list = generate_txs_list( received_txs, sent_txs, pubkey, ud_value, currency_symbol, uids, full_pubkey ) table_headers = [ @@ -105,7 +105,7 @@ def remove_duplicate_txs(received_txs: List, sent_txs: List) -> None: received_txs.remove(received_tx) -def generate_table( +def generate_txs_list( received_txs: List[Transaction], sent_txs: List[Transaction], pubkey: str, @@ -120,18 +120,18 @@ def generate_table( Sort txs temporarily """ - received_txs_table, sent_txs_table = ( + received_txs_list, sent_txs_list = ( [], [], ) # type: List[Transaction], List[Transaction] parse_received_tx( - received_txs_table, received_txs, pubkey, ud_value, uids, full_pubkey + received_txs_list, received_txs, pubkey, ud_value, uids, full_pubkey ) - parse_sent_tx(sent_txs_table, sent_txs, pubkey, ud_value, uids, full_pubkey) - txs_table = received_txs_table + sent_txs_table + parse_sent_tx(sent_txs_list, sent_txs, pubkey, ud_value, uids, full_pubkey) + txs_list = received_txs_list + sent_txs_list - txs_table.sort(key=itemgetter(0), reverse=True) - return txs_table + txs_list.sort(key=itemgetter(0), reverse=True) + return txs_list def parse_received_tx( diff --git a/tests/test_tx_history.py b/tests/test_tx_history.py index 12fd5da2..adfafad6 100644 --- a/tests/test_tx_history.py +++ b/tests/test_tx_history.py @@ -35,7 +35,7 @@ MAX_FULL_PUBKEY_LENGTH_WITH_CHECKSUM = ( ) # char `:` ==> 44 + 3 + 1 = 48 -def test_tx_history_generate_table_and_pubkey_uid_display(monkeypatch): +def test_tx_history_generate_txs_list_and_pubkey_uid_display(monkeypatch): def min_pubkey_length_with_uid(pubkey): # uid is at least one char : "<uid> - <pubkey>" adds min 4 chars to <pubkey> return pubkey + 4 @@ -53,7 +53,7 @@ def test_tx_history_generate_table_and_pubkey_uid_display(monkeypatch): patched_get_transactions_history(client, pubkey, received_txs, sent_txs) # simple table - txs_list = tx_history.generate_table( + txs_list = tx_history.generate_txs_list( received_txs, sent_txs, pubkey, @@ -68,7 +68,7 @@ def test_tx_history_generate_table_and_pubkey_uid_display(monkeypatch): assert len(tx_list[1]) == SHORT_PUBKEY_LENGTH_WITH_CHECKSUM # with uids - txs_list_uids = tx_history.generate_table( + txs_list_uids = tx_history.generate_txs_list( received_txs, sent_txs, pubkey, @@ -91,7 +91,7 @@ def test_tx_history_generate_table_and_pubkey_uid_display(monkeypatch): assert len(txs_list_uids[3][1]) == SHORT_PUBKEY_LENGTH_WITH_CHECKSUM # with full pubkeys - txs_list_full = tx_history.generate_table( + txs_list_full = tx_history.generate_txs_list( received_txs, sent_txs, pubkey, @@ -111,7 +111,7 @@ def test_tx_history_generate_table_and_pubkey_uid_display(monkeypatch): ) # with full pubkeys and uids - txs_list_uids_full = tx_history.generate_table( + txs_list_uids_full = tx_history.generate_txs_list( received_txs, sent_txs, pubkey, -- GitLab