Skip to content
Snippets Groups Projects
Commit b8bf6d51 authored by Moul's avatar Moul
Browse files

[mod] #194: tests: Use f-string

parent 5214297b
No related branches found
No related tags found
1 merge request!195#194, #376: Use f-string and sys.exit()
Pipeline #13768 passed
...@@ -21,7 +21,7 @@ from silkaj.cli import cli ...@@ -21,7 +21,7 @@ from silkaj.cli import cli
pubkey = "3rp7ahDGeXqffBQTnENiXEFXYS7BRjYmS33NbgfCuDc8" pubkey = "3rp7ahDGeXqffBQTnENiXEFXYS7BRjYmS33NbgfCuDc8"
checksum = "DFQ" checksum = "DFQ"
pubkey_checksum = pubkey + ":" + checksum pubkey_checksum = f"{pubkey}:{checksum}"
pubkey_seedhex_authfile = ( pubkey_seedhex_authfile = (
"3bc6f2484e441e40562155235cdbd8ce04c25e7df35bf5f87c067bf239db8511" "3bc6f2484e441e40562155235cdbd8ce04c25e7df35bf5f87c067bf239db8511"
) )
...@@ -31,7 +31,7 @@ pubkey_seedhex_authfile = ( ...@@ -31,7 +31,7 @@ pubkey_seedhex_authfile = (
"command, excepted_output", "command, excepted_output",
[ [
(["checksum", pubkey_checksum], "The checksum is valid"), (["checksum", pubkey_checksum], "The checksum is valid"),
(["checksum", pubkey + ":vAK"], "The checksum is invalid"), (["checksum", f"{pubkey}:vAK"], "The checksum is invalid"),
(["checksum", pubkey], pubkey_checksum), (["checksum", pubkey], pubkey_checksum),
(["checksum", "uid"], "Error: Wrong public key format"), (["checksum", "uid"], "Error: Wrong public key format"),
(["checksum"], MESSAGE), (["checksum"], MESSAGE),
...@@ -44,4 +44,4 @@ def test_checksum_command(command, excepted_output): ...@@ -44,4 +44,4 @@ def test_checksum_command(command, excepted_output):
with open("authfile", "w") as f: with open("authfile", "w") as f:
f.write(pubkey_seedhex_authfile) f.write(pubkey_seedhex_authfile)
result = CliRunner().invoke(cli, args=command) result = CliRunner().invoke(cli, args=command)
assert result.output == excepted_output + "\n" assert result.output == f"{excepted_output}\n"
...@@ -42,7 +42,7 @@ def test_gen_checksum(pubkey, checksum): ...@@ -42,7 +42,7 @@ def test_gen_checksum(pubkey, checksum):
], ],
) )
def test_validate_checksum(pubkey, checksum, expected, capsys): def test_validate_checksum(pubkey, checksum, expected, capsys):
pubkey_with_ck = str(pubkey + ":" + checksum) pubkey_with_ck = f"{pubkey}:{checksum}"
if expected == None: if expected == None:
assert pubkey == crypto_tools.validate_checksum(pubkey_with_ck) assert pubkey == crypto_tools.validate_checksum(pubkey_with_ck)
else: else:
......
...@@ -30,14 +30,8 @@ def test_display_amount(message, amount, currency_symbol): ...@@ -30,14 +30,8 @@ def test_display_amount(message, amount, currency_symbol):
amount_UD = round(amount / mock_ud_value, 2) amount_UD = round(amount / mock_ud_value, 2)
expected = [ expected = [
[ [
message + " (unit|relative)", f"{message} (unit|relative)",
str(amount / 100) f"{str(amount / 100)} {currency_symbol} | {str(amount_UD)} UD {currency_symbol}",
+ " "
+ currency_symbol
+ " | "
+ str(amount_UD)
+ " UD "
+ currency_symbol,
] ]
] ]
tx = list() tx = list()
...@@ -56,9 +50,9 @@ def test_display_amount(message, amount, currency_symbol): ...@@ -56,9 +50,9 @@ def test_display_amount(message, amount, currency_symbol):
def test_display_pubkey(message, pubkey, id, monkeypatch): def test_display_pubkey(message, pubkey, id, monkeypatch):
monkeypatch.setattr(wot_tools, "is_member", patched_is_member) monkeypatch.setattr(wot_tools, "is_member", patched_is_member)
expected = [[message + " (pubkey:checksum)", display_pubkey_and_checksum(pubkey)]] expected = [[f"{message} (pubkey:checksum)", display_pubkey_and_checksum(pubkey)]]
if id: if id:
expected.append([message + " (id)", id]) expected.append([f"{message} (id)", id])
tx = list() tx = list()
display_pubkey(tx, message, pubkey) display_pubkey(tx, message, pubkey)
assert tx == expected assert tx == expected
......
...@@ -55,8 +55,8 @@ def test_check_passed_blocks_range(from_block, to_block, capsys, monkeypatch): ...@@ -55,8 +55,8 @@ def test_check_passed_blocks_range(from_block, to_block, capsys, monkeypatch):
assert pytest_wrapped_e.value.code == FAILURE_EXIT_STATUS assert pytest_wrapped_e.value.code == FAILURE_EXIT_STATUS
captured = capsys.readouterr() captured = capsys.readouterr()
if to_block == HEAD_BLOCK + 1: if to_block == HEAD_BLOCK + 1:
expected = "Passed TO_BLOCK argument is bigger than the head block: " + str( expected = (
HEAD_BLOCK f"Passed TO_BLOCK argument is bigger than the head block: {str(HEAD_BLOCK)}"
) )
else: else:
expected = "TO_BLOCK should be bigger or equal to FROM_BLOCK\n" expected = "TO_BLOCK should be bigger or equal to FROM_BLOCK\n"
......
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