Release v1.0.0
Some checks failed
CI / Checks (push) Failing after 13m2s

This commit is contained in:
2025-08-20 21:00:50 +02:00
commit b4338e2769
401 changed files with 23576 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
from .association import * # noqa: F401,F403
from .save import * # noqa: F401,F403

View File

@@ -0,0 +1,165 @@
# -*- coding: utf-8 -*-
from __future__ import annotations
from django.utils.timezone import now
import pytest
from hotpocket_soa.dto.associations import AssociationWithTargetOut
@pytest.fixture
def association_factory(request: pytest.FixtureRequest):
default_account = request.getfixturevalue('account')
default_target = request.getfixturevalue('save')
def factory(account=None, target=None, **kwargs):
from hotpocket_backend_testing.factories.saves import AssociationFactory
return AssociationFactory(
account_uuid=(
account.pk
if account is not None
else default_account.pk
),
target=target or default_target,
**kwargs,
)
return factory
@pytest.fixture
def association(association_factory):
return association_factory()
@pytest.fixture
def association_out(association):
return AssociationWithTargetOut.model_validate(
association, from_attributes=True,
)
@pytest.fixture
def deleted_association(association_factory):
return association_factory(deleted_at=now())
@pytest.fixture
def deleted_association_out(deleted_association):
return AssociationWithTargetOut.model_validate(
deleted_association, from_attributes=True,
)
@pytest.fixture
def archived_association(association_factory):
return association_factory(archived_at=now())
@pytest.fixture
def archived_association_out(archived_association):
return AssociationWithTargetOut.model_validate(
archived_association, from_attributes=True,
)
@pytest.fixture
def starred_association(association_factory):
return association_factory(starred_at=now())
@pytest.fixture
def starred_association_out(starred_association):
return AssociationWithTargetOut.model_validate(
starred_association, from_attributes=True,
)
@pytest.fixture
def other_account_association(association_factory, other_account):
return association_factory(account=other_account)
@pytest.fixture
def other_account_association_out(other_account_association):
return AssociationWithTargetOut.model_validate(
other_account_association, from_attributes=True,
)
@pytest.fixture
def other_account_deleted_association(association_factory, other_account):
return association_factory(account=other_account, deleted_at=now())
@pytest.fixture
def other_account_deleted_association_out(other_account_deleted_association):
return AssociationWithTargetOut.model_validate(
other_account_deleted_association, from_attributes=True,
)
@pytest.fixture
def other_account_archived_association(association_factory, other_account):
return association_factory(account=other_account, archived_at=now())
@pytest.fixture
def other_account_archived_association_out(other_account_archived_association):
return AssociationWithTargetOut.model_validate(
other_account_archived_association, from_attributes=True,
)
@pytest.fixture
def other_account_starred_association(association_factory, other_account):
return association_factory(account=other_account, starred_at=now())
@pytest.fixture
def other_account_starred_association_out(other_account_starred_association):
return AssociationWithTargetOut.model_validate(
other_account_starred_association, from_attributes=True,
)
@pytest.fixture
def browsable_associations(association,
deleted_association,
archived_association,
starred_association,
other_account_association,
):
return [
association,
starred_association,
]
@pytest.fixture
def browsable_association_outs(browsable_associations):
return [
AssociationWithTargetOut.model_validate(obj, from_attributes=True)
for obj
in browsable_associations
]
@pytest.fixture
def paginatable_associations(association_factory):
result = [
association_factory()
for _ in range(0, 14)
]
return result[::-1]
@pytest.fixture
def paginatable_association_outs(paginatable_associations):
return [
AssociationWithTargetOut.model_validate(obj, from_attributes=True)
for obj
in paginatable_associations
]

View File

@@ -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)