You've already forked hotpocket
BTHLABS-50: Safari Web extension
Co-authored-by: Tomek Wójcik <labs@tomekwojcik.pl> Co-committed-by: Tomek Wójcik <labs@tomekwojcik.pl>
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
from .access_token import * # noqa: F401,F403
|
||||
from .account import * # noqa: F401,F403
|
||||
@@ -0,0 +1,122 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# type: ignore
|
||||
from __future__ import annotations
|
||||
|
||||
from django.utils.timezone import now
|
||||
import pytest
|
||||
|
||||
from hotpocket_soa.dto.accounts import AccessTokenOut
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def access_token_factory(request: pytest.FixtureRequest):
|
||||
default_account = request.getfixturevalue('account')
|
||||
|
||||
def factory(account=None, **kwargs):
|
||||
from hotpocket_backend_testing.factories.accounts import (
|
||||
AccessTokenFactory,
|
||||
)
|
||||
|
||||
return AccessTokenFactory(
|
||||
account_uuid=(
|
||||
account.pk
|
||||
if account is not None
|
||||
else default_account.pk
|
||||
),
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return factory
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def access_token(access_token_factory):
|
||||
return access_token_factory()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def access_token_out(access_token):
|
||||
return AccessTokenOut.model_validate(access_token, from_attributes=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def deleted_access_token(access_token_factory):
|
||||
return access_token_factory(deleted_at=now())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def deleted_access_token_out(deleted_access_token):
|
||||
return AccessTokenOut.model_validate(deleted_access_token, from_attributes=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def other_access_token(access_token_factory):
|
||||
return access_token_factory()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def other_access_token_out(other_access_token):
|
||||
return AccessTokenOut.model_validate(other_access_token, from_attributes=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def inactive_account_access_token(access_token_factory, inactive_account):
|
||||
return access_token_factory(account=inactive_account)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def inactive_account_access_token_out(access_token):
|
||||
return AccessTokenOut.model_validate(
|
||||
inactive_account_access_token, from_attributes=True,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def other_account_access_token(access_token_factory, other_account):
|
||||
return access_token_factory(account=other_account)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def other_account_access_token_out(other_account_access_token):
|
||||
return AccessTokenOut.model_validate(
|
||||
other_account_access_token, from_attributes=True,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def browsable_access_tokens(access_token,
|
||||
other_access_token,
|
||||
other_account_access_token,
|
||||
):
|
||||
return [
|
||||
access_token,
|
||||
other_access_token,
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def browsable_access_token_outs(browsable_access_tokens):
|
||||
return [
|
||||
AccessTokenOut.model_validate(obj, from_attributes=True)
|
||||
for obj
|
||||
in browsable_access_tokens
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def paginatable_access_tokens(access_token_factory):
|
||||
result = [
|
||||
access_token_factory()
|
||||
for _ in range(0, 12)
|
||||
]
|
||||
|
||||
return result[::-1]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def paginatable_access_token_outs(paginatable_access_tokens):
|
||||
return [
|
||||
AccessTokenOut.model_validate(obj, from_attributes=True)
|
||||
for obj
|
||||
in paginatable_access_tokens
|
||||
]
|
||||
Reference in New Issue
Block a user