test(tokens-repo): use mnemonic_from_hex consistently

This commit is contained in:
Houkime 2022-12-26 16:22:16 +00:00
parent 3ecfb2eacb
commit 67872d7c55

View file

@ -33,6 +33,10 @@ ORIGINAL_DEVICE_NAMES = [
]
def mnemonic_from_hex(hexkey):
return Mnemonic(language="english").to_mnemonic(bytes.fromhex(hexkey))
@pytest.fixture
def empty_keys(mocker, datadir):
mocker.patch("selfprivacy_api.utils.TOKENS_FILE", new=datadir / "empty_keys.json")
@ -388,9 +392,7 @@ def test_use_mnemonic_expired_recovery_key(
with pytest.raises(RecoveryKeyNotFound):
token = repo.use_mnemonic_recovery_key(
mnemonic_phrase=Mnemonic(language="english").to_mnemonic(
bytes.fromhex(recovery_key.key)
),
mnemonic_phrase=mnemonic_from_hex(recovery_key.key),
device_name="newdevice",
)
@ -455,9 +457,7 @@ def test_use_mnemonic_recovery_key(some_tokens_repo, recovery_key_uses_left):
recovery_key = repo.get_recovery_key()
token = repo.use_mnemonic_recovery_key(
mnemonic_phrase=Mnemonic(language="english").to_mnemonic(
bytes.fromhex(recovery_key.key)
),
mnemonic_phrase=mnemonic_from_hex(recovery_key.key),
device_name="newdevice",
)
@ -531,10 +531,6 @@ def test_use_not_exists_mnemonic_new_device_key(
)
def mnemonic_from_hex(hexkey):
return Mnemonic(language="english").to_mnemonic(bytes.fromhex(hexkey))
def test_use_mnemonic_new_device_key(empty_repo):
repo = empty_repo
key = repo.get_new_device_key()