diff --git a/tests/patched/auth.py b/tests/patched/auth.py new file mode 100644 index 0000000000000000000000000000000000000000..c681ed47cdea8b333c6d2c144fea43f224781fee --- /dev/null +++ b/tests/patched/auth.py @@ -0,0 +1,17 @@ +# 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" diff --git a/tests/test_auth.py b/tests/test_auth.py new file mode 100644 index 0000000000000000000000000000000000000000..a238ee6d8a1deb32a7c8211f3604fae47312da7e --- /dev/null +++ b/tests/test_auth.py @@ -0,0 +1,32 @@ +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()