Skip to content
Snippets Groups Projects
Commit 5511abd3 authored by matograine's avatar matograine
Browse files

[test] #307 Create test_tui.py file

* move test_display_amount() and test_display_pubkey() from test_unit_tx.py to test_tui.py
parent e0b524fe
No related branches found
No related tags found
No related merge requests found
import pytest
from silkaj.tui import display_pubkey, display_amount
from silkaj.constants import G1_SYMBOL
import patched
# display_amount()
@pytest.mark.parametrize(
"message, amount, currency_symbol", [("Total", 1000, G1_SYMBOL)]
)
def test_display_amount(message, amount, currency_symbol, monkeypatch):
ud_value = patched.mock_ud_value
amount_UD = round(amount / ud_value, 4)
expected = [
[
message + " (unit|relative)",
str(amount / 100)
+ " "
+ currency_symbol
+ " | "
+ str(amount_UD)
+ " UD "
+ currency_symbol,
]
]
tx = list()
display_amount(tx, message, amount, ud_value, currency_symbol)
assert tx == expected
# display_pubkey()
@pytest.mark.parametrize(
"message, pubkey, id",
[
("From", "BFb5yv8z1fowR6Z8mBXTALy5z7gHfMU976WtXhmRsUMh", "riri"),
("To", "DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw", ""),
],
)
@pytest.mark.asyncio
async def test_display_pubkey(message, pubkey, id, monkeypatch):
monkeypatch.setattr("silkaj.wot.is_member", patched.is_member)
expected = [[message + " (pubkey)", pubkey]]
if id:
expected.append([message + " (id)", id])
tx = list()
await display_pubkey(tx, message, pubkey)
assert tx == expected
......@@ -7,7 +7,6 @@ from silkaj.tx import (
generate_transaction_document,
get_list_input_for_transaction,
)
from silkaj.tui import display_pubkey, display_amount
from silkaj.money import UDValue
from silkaj.constants import G1_SYMBOL, CENT_MULT_TO_UNIT, MINIMAL_TX_AMOUNT
from duniterpy.documents.transaction import (
......@@ -31,50 +30,6 @@ def test_truncBase(amount, base, expected):
assert truncBase(amount, base) == expected
# display_amount()
@pytest.mark.parametrize(
"message, amount, currency_symbol", [("Total", 1000, G1_SYMBOL)]
)
def test_display_amount(message, amount, currency_symbol, monkeypatch):
ud_value = patched.mock_ud_value
amount_UD = round(amount / ud_value, 4)
expected = [
[
message + " (unit|relative)",
str(amount / 100)
+ " "
+ currency_symbol
+ " | "
+ str(amount_UD)
+ " UD "
+ currency_symbol,
]
]
tx = list()
display_amount(tx, message, amount, ud_value, currency_symbol)
assert tx == expected
# display_pubkey()
@pytest.mark.parametrize(
"message, pubkey, id",
[
("From", "BFb5yv8z1fowR6Z8mBXTALy5z7gHfMU976WtXhmRsUMh", "riri"),
("To", "DBM6F5ChMJzpmkUdL5zD9UXKExmZGfQ1AgPDQy4MxSBw", ""),
],
)
@pytest.mark.asyncio
async def test_display_pubkey(message, pubkey, id, monkeypatch):
monkeypatch.setattr("silkaj.wot.is_member", patched.is_member)
expected = [[message + " (pubkey)", pubkey]]
if id:
expected.append([message + " (id)", id])
tx = list()
await display_pubkey(tx, message, pubkey)
assert tx == expected
# transaction_confirmation()
@pytest.mark.parametrize(
"issuer_pubkey, pubkey_balance, tx_amounts, outputAddresses, outputBackChange, comment, currency_symbol",
......
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