Skip to content

Commit

Permalink
test: 테스트 코드 스레드 픽스처 호출 지점 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
E5presso committed Oct 2, 2024
1 parent a6c82e6 commit d59cafb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,27 @@ def get_config() -> RabbitMQConnectionConfig:
yield context


@pytest.fixture(name="managed_thread", scope="function")
@pytest.fixture(name="managed_thread", scope="function", autouse=True)
def get_managed_thread_fixture(
context: ApplicationContext,
) -> Generator[ManagedThread, Any, None]:
thread: ManagedThread = ManagedThread(
context.get(IManagedThreadAction),
"RabbitMQ Sync Thread",
)
thread.start()
yield thread
thread.stop()


@pytest.fixture(name="async_managed_thread", scope="function")
@pytest.fixture(name="async_managed_thread", scope="function", autouse=True)
def get_async_managed_thread_fixture(
context: ApplicationContext,
) -> Generator[AsyncManagedThread, Any, None]:
thread: AsyncManagedThread = AsyncManagedThread(
context.get(IAsyncManagedThreadAction),
"RabbitMQ Async Thread",
)
thread.start()
yield thread
thread.stop()
11 changes: 2 additions & 9 deletions tests/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@
IAsyncEventPublisher,
IEventPublisher,
)
from spakky.threading.managed_thread import AsyncManagedThread, ManagedThread

from tests.apps.dummy import DummyEventHandler, SampleEvent


def test_synchronous_event_publish_and_consume(
context: ApplicationContext, managed_thread: ManagedThread
) -> None:
managed_thread.start()
def test_synchronous_event(context: ApplicationContext) -> None:
publisher = context.get(IEventPublisher)
publisher.publish(SampleEvent(message="Hello, World!"))
publisher.publish(SampleEvent(message="Goodbye, World!"))
Expand All @@ -25,10 +21,7 @@ def test_synchronous_event_publish_and_consume(


@pytest.mark.asyncio
async def test_asynchronous_event_publish_and_consume(
context: ApplicationContext, async_managed_thread: AsyncManagedThread
) -> None:
async_managed_thread.start()
async def test_asynchronous_event(context: ApplicationContext) -> None:
publisher = context.get(IAsyncEventPublisher)
await publisher.publish(SampleEvent(message="Hello, World!"))
await publisher.publish(SampleEvent(message="Goodbye, World!"))
Expand Down

0 comments on commit d59cafb

Please sign in to comment.