mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-26 05:51:29 +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 json
|
||||||
|
import datetime
|
||||||
from mnemonic import Mnemonic
|
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):
|
def read_json(file_path):
|
||||||
with open(file_path, "r", encoding="utf-8") as file:
|
with open(file_path, "r", encoding="utf-8") as file:
|
||||||
|
|
|
@ -5,6 +5,11 @@ import datetime
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tests.conftest import TOKENS_FILE_CONTENTS
|
from tests.conftest import TOKENS_FILE_CONTENTS
|
||||||
|
from tests.common import (
|
||||||
|
RECOVERY_KEY_VALIDATION_DATETIME,
|
||||||
|
DEVICE_KEY_VALIDATION_DATETIME,
|
||||||
|
NearFuture,
|
||||||
|
)
|
||||||
|
|
||||||
DATE_FORMATS = [
|
DATE_FORMATS = [
|
||||||
"%Y-%m-%dT%H:%M:%S.%fZ",
|
"%Y-%m-%dT%H:%M:%S.%fZ",
|
||||||
|
@ -13,16 +18,6 @@ DATE_FORMATS = [
|
||||||
"%Y-%m-%d %H:%M:%S.%f",
|
"%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):
|
def assert_original(client):
|
||||||
new_tokens = rest_get_tokens_info(client)
|
new_tokens = rest_get_tokens_info(client)
|
||||||
|
|
Loading…
Reference in a new issue