Refactor code structure for improved readability and maintainability

This commit is contained in:
k1nq
2026-09-16 14:27:32 +05:00
parent 01028f440e
commit 2b35fa9a6d
17 changed files with 1475 additions and 3 deletions
+30
View File
@@ -0,0 +1,30 @@
import uuid
from unittest.mock import AsyncMock
import pytest
from faststream.exceptions import RejectMessage
from app import consumer
from app.schemas import PaymentCreatedEvent
async def test_handler_delegates_to_processor(monkeypatch: pytest.MonkeyPatch) -> None:
processor = AsyncMock()
monkeypatch.setattr(consumer, "processor", processor)
event = PaymentCreatedEvent(payment_id=uuid.uuid4())
await consumer.handle_payment(event)
processor.process.assert_awaited_once_with(event)
async def test_handler_rejects_after_processor_failure(
monkeypatch: pytest.MonkeyPatch,
) -> None:
processor = AsyncMock()
processor.process.side_effect = RuntimeError("exhausted")
monkeypatch.setattr(consumer, "processor", processor)
event = PaymentCreatedEvent(payment_id=uuid.uuid4())
with pytest.raises(RejectMessage):
await consumer.handle_payment(event)