Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dimastbk committed May 24, 2024
1 parent f9b852c commit 7cb847c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/unit/worker/worker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from uuid import uuid4

import grpc
from mock import AsyncMock
import pytest

from pyzeebe import ExceptionHandler, TaskDecorator, ZeebeTaskRouter
Expand Down Expand Up @@ -162,6 +163,24 @@ async def test_worker_with_exception_handler(

exception_handler.assert_called_once()

@pytest.mark.asyncio
async def test_worker_and_router_with_exception_handler(
self,
zeebe_worker: ZeebeWorker,
router: ZeebeTaskRouter,
mocked_job_with_adapter: Job,
):
exception_handler_router = AsyncMock()
exception_handler_worker = AsyncMock()
router.exception_handler(exception_handler_router)
zeebe_worker.exception_handler(exception_handler_worker)
task = self.include_router_with_task_error(zeebe_worker, router)

await task.job_handler(mocked_job_with_adapter)

exception_handler_router.assert_called_once()
exception_handler_worker.assert_not_called()

@staticmethod
def include_router_with_task(zeebe_worker: ZeebeWorker, router: ZeebeTaskRouter, task_type: str = None) -> Task:
task_type = task_type or str(uuid4())
Expand Down

0 comments on commit 7cb847c

Please sign in to comment.