mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-29 07:21:27 +00:00
test(tokens-repo): make empty_keys fixture (and derived) shareable
This commit is contained in:
parent
7c2e1dcf25
commit
3e7ea01a42
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"tokens": [
|
|
||||||
{
|
|
||||||
"token": "KG9ni-B-CMPk327Zv1qC7YBQaUGaBUcgdkvMvQ2atFI",
|
|
||||||
"name": "primary_token",
|
|
||||||
"date": "2022-07-15 17:41:31.675698"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -32,22 +32,37 @@ ORIGINAL_DEVICE_NAMES = [
|
||||||
"forth_token",
|
"forth_token",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
EMPTY_KEYS_JSON = """
|
||||||
|
{
|
||||||
|
"tokens": [
|
||||||
|
{
|
||||||
|
"token": "KG9ni-B-CMPk327Zv1qC7YBQaUGaBUcgdkvMvQ2atFI",
|
||||||
|
"name": "primary_token",
|
||||||
|
"date": "2022-07-15 17:41:31.675698"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
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))
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def empty_keys(mocker, datadir):
|
def empty_keys(mocker, tmpdir):
|
||||||
mocker.patch("selfprivacy_api.utils.TOKENS_FILE", new=datadir / "empty_keys.json")
|
tokens_file = tmpdir / "empty_keys.json"
|
||||||
assert read_json(datadir / "empty_keys.json")["tokens"] == [
|
with open(tokens_file, "w") as file:
|
||||||
|
file.write(EMPTY_KEYS_JSON)
|
||||||
|
mocker.patch("selfprivacy_api.utils.TOKENS_FILE", new=tokens_file)
|
||||||
|
assert read_json(tokens_file)["tokens"] == [
|
||||||
{
|
{
|
||||||
"token": "KG9ni-B-CMPk327Zv1qC7YBQaUGaBUcgdkvMvQ2atFI",
|
"token": "KG9ni-B-CMPk327Zv1qC7YBQaUGaBUcgdkvMvQ2atFI",
|
||||||
"name": "primary_token",
|
"name": "primary_token",
|
||||||
"date": "2022-07-15 17:41:31.675698",
|
"date": "2022-07-15 17:41:31.675698",
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
return datadir
|
return tmpdir
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"tokens": [
|
|
||||||
{
|
|
||||||
"token": "KG9ni-B-CMPk327Zv1qC7YBQaUGaBUcgdkvMvQ2atFI",
|
|
||||||
"name": "primary_token",
|
|
||||||
"date": "2022-07-15 17:41:31.675698"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
Loading…
Reference in a new issue