mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-09-22 09:26:35 +08:00
fix(plugin): return not found after removal (#2483)
Co-authored-by: Hyu <chenhyu@proton.me>
This commit is contained in:
@@ -1913,9 +1913,14 @@ class PluginRuntimeConnector(ManagedRuntimeConnector):
|
|||||||
|
|
||||||
return plugins
|
return plugins
|
||||||
|
|
||||||
async def get_plugin_info(self, author: str, plugin_name: str) -> dict[str, Any]:
|
async def get_plugin_info(self, author: str, plugin_name: str) -> dict[str, Any] | None:
|
||||||
runtime_handler = self._runtime_handler()
|
runtime_handler = self._runtime_handler()
|
||||||
binding = await self._target_binding(author, plugin_name)
|
try:
|
||||||
|
binding = await self._target_binding(author, plugin_name)
|
||||||
|
except ValueError as exc:
|
||||||
|
if str(exc) == f'Plugin {author}/{plugin_name} is not installed in this Workspace':
|
||||||
|
return None
|
||||||
|
raise
|
||||||
with runtime_handler.installation_scope(binding):
|
with runtime_handler.installation_scope(binding):
|
||||||
return await runtime_handler.get_plugin_info(author, plugin_name)
|
return await runtime_handler.get_plugin_info(author, plugin_name)
|
||||||
|
|
||||||
|
|||||||
@@ -640,6 +640,19 @@ class TestGetPluginInfo:
|
|||||||
connector.handler.get_plugin_info.assert_called_once_with('author', 'plugin')
|
connector.handler.get_plugin_info.assert_called_once_with('author', 'plugin')
|
||||||
assert result == {'manifest': {'metadata': {'name': 'plugin'}}}
|
assert result == {'manifest': {'metadata': {'name': 'plugin'}}}
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_returns_none_when_plugin_is_not_installed(self):
|
||||||
|
connector = create_mock_connector()
|
||||||
|
configure_handler(connector, AsyncMock())
|
||||||
|
connector._target_binding = AsyncMock(
|
||||||
|
side_effect=ValueError('Plugin author/plugin is not installed in this Workspace')
|
||||||
|
)
|
||||||
|
|
||||||
|
result = await connector.get_plugin_info('author', 'plugin')
|
||||||
|
|
||||||
|
assert result is None
|
||||||
|
connector.handler.get_plugin_info.assert_not_awaited()
|
||||||
|
|
||||||
|
|
||||||
class TestSetPluginConfig:
|
class TestSetPluginConfig:
|
||||||
"""Tests for set_plugin_config method."""
|
"""Tests for set_plugin_config method."""
|
||||||
|
|||||||
Reference in New Issue
Block a user