Skip to content
Snippets Groups Projects
Commit 9a353cea authored by matograine's avatar matograine
Browse files

[test] #197: add test for auth_method()

* add patched auth functions
parent d004c799
No related branches found
No related tags found
1 merge request!130#213: Write unit tests for the transaction command
# This file contains patches for auth functions.
def patched_auth_by_seed():
return "call_auth_by_seed"
def patched_auth_by_wif():
return "call_auth_by_wif"
def patched_auth_by_auth_file():
return "call_auth_by_auth_file"
def patched_auth_by_scrypt():
return "call_auth_by_scrypt"
import pytest
import click
from silkaj import auth
from patched.auth import (
patched_auth_by_seed,
patched_auth_by_wif,
patched_auth_by_auth_file,
patched_auth_by_scrypt,
)
# test auth_method
@pytest.mark.parametrize(
"seed, file, wif, auth_method_called",
[
(True, False, False, "call_auth_by_seed"),
(False, True, False, "call_auth_by_auth_file"),
(False, False, True, "call_auth_by_wif"),
(False, False, False, "call_auth_by_scrypt"),
],
)
def test_auth_method(seed, file, wif, auth_method_called, monkeypatch):
monkeypatch.setattr("silkaj.auth.auth_by_seed", patched_auth_by_seed)
monkeypatch.setattr("silkaj.auth.auth_by_wif", patched_auth_by_wif)
monkeypatch.setattr("silkaj.auth.auth_by_auth_file", patched_auth_by_auth_file)
monkeypatch.setattr("silkaj.auth.auth_by_scrypt", patched_auth_by_scrypt)
ctx = click.Context(
click.Command(""), obj={"AUTH_SEED": seed, "AUTH_FILE": file, "AUTH_WIF": wif}
)
with ctx:
assert auth_method_called == auth.auth_method()
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