fix!: removed .commit() from repository level

This commit is contained in:
2026-08-24 11:07:26 +07:00
parent 8d1b753b99
commit a374501e4d
22 changed files with 177 additions and 180 deletions

View File

@@ -6,8 +6,9 @@ from schemas.enums import NotificationType
from services.notifications import collect_subscription_notifications
class FakeSession:
class FakeUnitOfWork:
def __init__(self, subscriptions_by_period):
self.session = self
self.subscriptions_by_period = iter(subscriptions_by_period)
self.executed = []
self.committed = False
@@ -25,7 +26,7 @@ class FakeSession:
def test_collects_notification_for_each_expiry_period():
now = datetime(2026, 8, 20, tzinfo=UTC)
session = FakeSession(
uow = FakeUnitOfWork(
[
[SimpleNamespace(id=1, expires_at=now + timedelta(days=6))],
[SimpleNamespace(id=2, expires_at=now + timedelta(days=2))],
@@ -34,11 +35,11 @@ def test_collects_notification_for_each_expiry_period():
]
)
created = asyncio.run(collect_subscription_notifications(session, now))
created = asyncio.run(collect_subscription_notifications(uow, now))
assert created == len(session.executed)
assert session.committed
assert [statement.compile().params["notify_type_m0"] for statement in session.executed] == [
assert created == len(uow.executed)
assert uow.committed
assert [statement.compile().params["notify_type_m0"] for statement in uow.executed] == [
NotificationType.SEVEN_DAYS,
NotificationType.THREE_DAYS,
NotificationType.ONE_DAY,