Skip to content

Commit

Permalink
Fix client hub tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vadim-su committed Nov 10, 2024
1 parent 7203a64 commit 8a00d82
Showing 3 changed files with 41 additions and 4 deletions.
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -203,3 +203,8 @@ quote-style = "single"

[tool.uv.workspace]
members = ["examples/echo", "examples/levels"]

[dependency-groups]
dev = [
"python-git>=2018.2.1",
]
9 changes: 6 additions & 3 deletions tests/test_client_hub.py
Original file line number Diff line number Diff line change
@@ -14,10 +14,11 @@ async def test_create_hub_without_session() -> None:
assert hub.session


async def test_setup_single_client_group(mocker: MockerFixture) -> None:
async def test_connect(mocker: MockerFixture) -> None:
"""Test setup_single_client_group method."""
mock_gather = mocker.patch('asyncio.gather', new=mocker.async_stub('gather'))
mock_client_group_class = mocker.patch('asyncord.client_hub.ClientGroup')
mock_client_group_class.return_value.close = AsyncMock()

async with ClientHub.connect(auth='token', session=Mock()) as client_group:
mock_client_group_class.assert_called_once()
@@ -28,11 +29,13 @@ async def test_setup_single_client_group(mocker: MockerFixture) -> None:
mock_client_group.connect.assert_called_once()


async def test_setup_with_dispatcher(mocker: MockerFixture, caplog: pytest.LogCaptureFixture) -> None:
async def test_connect_with_dispatcher(mocker: MockerFixture, caplog: pytest.LogCaptureFixture) -> None:
"""Test setup method with a dispatcher."""
mock_gather = mocker.patch('asyncio.gather', new=mocker.async_stub('gather'))
hub_context = ClientHub.connect(auth='token', session=Mock(), dispatcher=Mock())
mocker.patch('asyncord.client_hub.ClientGroup')
mock_client_group_class = mocker.patch('asyncord.client_hub.ClientGroup')
mock_client_group_class.return_value.close = AsyncMock()

with caplog.at_level(logging.WARNING):
async with hub_context:
pass
31 changes: 30 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8a00d82

Please sign in to comment.