Skip to content

Commit e2a7ebc

Browse files
committed
test(command-management): inline refresh fixtures
1 parent f6eb33c commit e2a7ebc

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

tests/test_command_platform_refresh.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@
77
from astrbot.dashboard.services.command_service import CommandService
88

99

10-
def _build_service():
10+
@pytest.mark.asyncio
11+
async def test_toggle_command_refreshes_platform_commands(monkeypatch):
1112
platform = SimpleNamespace(refresh_registered_commands=AsyncMock())
1213
platform_manager = SimpleNamespace(get_insts=lambda: [platform])
1314
lifecycle = SimpleNamespace(platform_manager=platform_manager)
14-
return CommandService({}, lifecycle), platform
15-
16-
17-
@pytest.mark.asyncio
18-
async def test_toggle_command_refreshes_platform_commands(monkeypatch):
19-
service, platform = _build_service()
15+
service = CommandService({}, lifecycle)
2016
toggle = AsyncMock()
2117
monkeypatch.setattr(command_service_module, "toggle_command", toggle)
2218
monkeypatch.setattr(
@@ -41,7 +37,10 @@ async def test_toggle_command_refreshes_platform_commands(monkeypatch):
4137

4238
@pytest.mark.asyncio
4339
async def test_rename_command_refreshes_platform_commands(monkeypatch):
44-
service, platform = _build_service()
40+
platform = SimpleNamespace(refresh_registered_commands=AsyncMock())
41+
platform_manager = SimpleNamespace(get_insts=lambda: [platform])
42+
lifecycle = SimpleNamespace(platform_manager=platform_manager)
43+
service = CommandService({}, lifecycle)
4544
rename = AsyncMock()
4645
monkeypatch.setattr(command_service_module, "rename_command", rename)
4746
monkeypatch.setattr(

0 commit comments

Comments
 (0)