Skip to content
Snippets Groups Projects
Commit 3063ef4d authored by matograine's avatar matograine Committed by Moul
Browse files

[mod] #203 reformat tx_history: rename generate_table to generate_txs_list

parent 329896a5
No related branches found
No related tags found
1 merge request!199#203: Harmonize tables style using Texttable
...@@ -50,7 +50,7 @@ def transaction_history(pubkey: str, uids: bool, full_pubkey: bool) -> None: ...@@ -50,7 +50,7 @@ def transaction_history(pubkey: str, uids: bool, full_pubkey: bool) -> None:
get_transactions_history(client, pubkey, received_txs, sent_txs) get_transactions_history(client, pubkey, received_txs, sent_txs)
remove_duplicate_txs(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 received_txs, sent_txs, pubkey, ud_value, currency_symbol, uids, full_pubkey
) )
table_headers = [ table_headers = [
...@@ -105,7 +105,7 @@ def remove_duplicate_txs(received_txs: List, sent_txs: List) -> None: ...@@ -105,7 +105,7 @@ def remove_duplicate_txs(received_txs: List, sent_txs: List) -> None:
received_txs.remove(received_tx) received_txs.remove(received_tx)
def generate_table( def generate_txs_list(
received_txs: List[Transaction], received_txs: List[Transaction],
sent_txs: List[Transaction], sent_txs: List[Transaction],
pubkey: str, pubkey: str,
...@@ -120,18 +120,18 @@ def generate_table( ...@@ -120,18 +120,18 @@ def generate_table(
Sort txs temporarily Sort txs temporarily
""" """
received_txs_table, sent_txs_table = ( received_txs_list, sent_txs_list = (
[], [],
[], [],
) # type: List[Transaction], List[Transaction] ) # type: List[Transaction], List[Transaction]
parse_received_tx( 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) parse_sent_tx(sent_txs_list, sent_txs, pubkey, ud_value, uids, full_pubkey)
txs_table = received_txs_table + sent_txs_table txs_list = received_txs_list + sent_txs_list
txs_table.sort(key=itemgetter(0), reverse=True) txs_list.sort(key=itemgetter(0), reverse=True)
return txs_table return txs_list
def parse_received_tx( def parse_received_tx(
......
...@@ -35,7 +35,7 @@ MAX_FULL_PUBKEY_LENGTH_WITH_CHECKSUM = ( ...@@ -35,7 +35,7 @@ MAX_FULL_PUBKEY_LENGTH_WITH_CHECKSUM = (
) # char `:` ==> 44 + 3 + 1 = 48 ) # 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): def min_pubkey_length_with_uid(pubkey):
# uid is at least one char : "<uid> - <pubkey>" adds min 4 chars to <pubkey> # uid is at least one char : "<uid> - <pubkey>" adds min 4 chars to <pubkey>
return pubkey + 4 return pubkey + 4
...@@ -53,7 +53,7 @@ def test_tx_history_generate_table_and_pubkey_uid_display(monkeypatch): ...@@ -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) patched_get_transactions_history(client, pubkey, received_txs, sent_txs)
# simple table # simple table
txs_list = tx_history.generate_table( txs_list = tx_history.generate_txs_list(
received_txs, received_txs,
sent_txs, sent_txs,
pubkey, pubkey,
...@@ -68,7 +68,7 @@ def test_tx_history_generate_table_and_pubkey_uid_display(monkeypatch): ...@@ -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 assert len(tx_list[1]) == SHORT_PUBKEY_LENGTH_WITH_CHECKSUM
# with uids # with uids
txs_list_uids = tx_history.generate_table( txs_list_uids = tx_history.generate_txs_list(
received_txs, received_txs,
sent_txs, sent_txs,
pubkey, pubkey,
...@@ -91,7 +91,7 @@ def test_tx_history_generate_table_and_pubkey_uid_display(monkeypatch): ...@@ -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 assert len(txs_list_uids[3][1]) == SHORT_PUBKEY_LENGTH_WITH_CHECKSUM
# with full pubkeys # with full pubkeys
txs_list_full = tx_history.generate_table( txs_list_full = tx_history.generate_txs_list(
received_txs, received_txs,
sent_txs, sent_txs,
pubkey, pubkey,
...@@ -111,7 +111,7 @@ def test_tx_history_generate_table_and_pubkey_uid_display(monkeypatch): ...@@ -111,7 +111,7 @@ def test_tx_history_generate_table_and_pubkey_uid_display(monkeypatch):
) )
# with full pubkeys and uids # with full pubkeys and uids
txs_list_uids_full = tx_history.generate_table( txs_list_uids_full = tx_history.generate_txs_list(
received_txs, received_txs,
sent_txs, sent_txs,
pubkey, pubkey,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment