You've already forked hotpocket
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
|
||||
from django.utils.timezone import now
|
||||
import pytest
|
||||
|
||||
from hotpocket_soa.dto.saves import SaveOut
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def save_url_factory():
|
||||
def factory():
|
||||
return f'https://{uuid.uuid4()}.local/'
|
||||
|
||||
return factory
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def save_url(save_url_factory):
|
||||
return save_url_factory()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def save_factory(request: pytest.FixtureRequest):
|
||||
default_account = request.getfixturevalue('account')
|
||||
default_url = request.getfixturevalue('save_url')
|
||||
|
||||
def factory(account=None, **kwargs):
|
||||
from hotpocket_backend_testing.factories.saves import SaveFactory
|
||||
|
||||
if 'url' not in kwargs:
|
||||
kwargs['url'] = default_url
|
||||
|
||||
return SaveFactory(
|
||||
account_uuid=(
|
||||
account.pk
|
||||
if account is not None
|
||||
else default_account.pk
|
||||
),
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return factory
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def save(save_factory):
|
||||
return save_factory()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def save_out(save):
|
||||
return SaveOut.model_validate(save, from_attributes=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def other_save(save_factory, save_url_factory):
|
||||
return save_factory(url=save_url_factory())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def other_save_out(other_save):
|
||||
return SaveOut.model_validate(other_save, from_attributes=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def processed_save(save_factory, save_url_factory):
|
||||
return save_factory(url=save_url_factory(), last_processed_at=now())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def processed_save_out(processed_save):
|
||||
return SaveOut.model_validate(processed_save, from_attributes=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def netloc_banned_save(save_factory, save_url_factory):
|
||||
return save_factory(url=save_url_factory(), is_netloc_banned=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def netloc_banned_save_out(netloc_banned_save):
|
||||
return SaveOut.model_validate(netloc_banned_save, from_attributes=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def deleted_save(save_factory, save_url_factory):
|
||||
return save_factory(url=save_url_factory(), deleted_at=now())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def deleted_save_out(deleted_save):
|
||||
return SaveOut.model_validate(deleted_save, from_attributes=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def other_account_save(save_factory, other_account, save_url_factory):
|
||||
return save_factory(account=other_account, url=save_url_factory())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def other_account_save_out(other_account_save):
|
||||
return SaveOut.model_validate(other_account_save, from_attributes=True)
|
||||
Reference in New Issue
Block a user