mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 20:11:30 +00:00
test(tokens-repo): make empty_tokens fixture, even more minimal
This commit is contained in:
parent
3e7ea01a42
commit
8065921862
|
@ -44,6 +44,8 @@ EMPTY_KEYS_JSON = """
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
EMPTY_TOKENS_JSON = ' {"tokens": []}'
|
||||||
|
|
||||||
|
|
||||||
def mnemonic_from_hex(hexkey):
|
def mnemonic_from_hex(hexkey):
|
||||||
return Mnemonic(language="english").to_mnemonic(bytes.fromhex(hexkey))
|
return Mnemonic(language="english").to_mnemonic(bytes.fromhex(hexkey))
|
||||||
|
@ -65,6 +67,16 @@ def empty_keys(mocker, tmpdir):
|
||||||
return tmpdir
|
return tmpdir
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def empty_tokens(mocker, tmpdir):
|
||||||
|
tokens_file = tmpdir / "empty_tokens.json"
|
||||||
|
with open(tokens_file, "w") as file:
|
||||||
|
file.write(EMPTY_TOKENS_JSON)
|
||||||
|
mocker.patch("selfprivacy_api.utils.TOKENS_FILE", new=tokens_file)
|
||||||
|
assert read_json(tokens_file)["tokens"] == []
|
||||||
|
return tmpdir
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_new_device_key_generate(mocker):
|
def mock_new_device_key_generate(mocker):
|
||||||
mock = mocker.patch(
|
mock = mocker.patch(
|
||||||
|
@ -153,7 +165,7 @@ def mock_recovery_key_generate(mocker):
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def empty_json_repo(empty_keys):
|
def empty_json_repo(empty_tokens):
|
||||||
repo = JsonTokensRepository()
|
repo = JsonTokensRepository()
|
||||||
for token in repo.get_tokens():
|
for token in repo.get_tokens():
|
||||||
repo.delete_token(token)
|
repo.delete_token(token)
|
||||||
|
|
Loading…
Reference in a new issue