mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 12:11:26 +00:00
test(tokens-repo): move timewarping to test commons
This commit is contained in:
parent
0aaa90f54a
commit
f5faf84a2b
|
@ -1,6 +1,17 @@
|
|||
import json
|
||||
import datetime
|
||||
from mnemonic import Mnemonic
|
||||
|
||||
# for expiration tests. If headache, consider freezegun
|
||||
RECOVERY_KEY_VALIDATION_DATETIME = "selfprivacy_api.models.tokens.recovery_key.datetime"
|
||||
DEVICE_KEY_VALIDATION_DATETIME = "selfprivacy_api.models.tokens.new_device_key.datetime"
|
||||
|
||||
|
||||
class NearFuture(datetime.datetime):
|
||||
@classmethod
|
||||
def now(cls):
|
||||
return datetime.datetime.now() + datetime.timedelta(minutes=13)
|
||||
|
||||
|
||||
def read_json(file_path):
|
||||
with open(file_path, "r", encoding="utf-8") as file:
|
||||
|
|
|
@ -5,6 +5,11 @@ import datetime
|
|||
import pytest
|
||||
|
||||
from tests.conftest import TOKENS_FILE_CONTENTS
|
||||
from tests.common import (
|
||||
RECOVERY_KEY_VALIDATION_DATETIME,
|
||||
DEVICE_KEY_VALIDATION_DATETIME,
|
||||
NearFuture,
|
||||
)
|
||||
|
||||
DATE_FORMATS = [
|
||||
"%Y-%m-%dT%H:%M:%S.%fZ",
|
||||
|
@ -13,16 +18,6 @@ DATE_FORMATS = [
|
|||
"%Y-%m-%d %H:%M:%S.%f",
|
||||
]
|
||||
|
||||
# for expiration tests. If headache, consider freezegun
|
||||
RECOVERY_KEY_VALIDATION_DATETIME = "selfprivacy_api.models.tokens.recovery_key.datetime"
|
||||
DEVICE_KEY_VALIDATION_DATETIME = "selfprivacy_api.models.tokens.new_device_key.datetime"
|
||||
|
||||
|
||||
class NearFuture(datetime.datetime):
|
||||
@classmethod
|
||||
def now(cls):
|
||||
return datetime.datetime.now() + datetime.timedelta(minutes=13)
|
||||
|
||||
|
||||
def assert_original(client):
|
||||
new_tokens = rest_get_tokens_info(client)
|
||||
|
|
Loading…
Reference in a new issue