Files
LangBot/tests/unit_tests/plugin/conftest.py
huanghuoguoguoandClaude Opus 5.5 97ef5b457d feat(api): provide Workspace and execution API foundations (#2648)
Unified Workspace and execution APIs for LangBot (#2639).

- Versioned Application API shared by HTTP, MCP, the Workspace assistant
  and plugins, with one authorization and error contract.
- Execution API facade for every plugin and Runner action.
- Plugin installation permissions: manifest declarations, member
  confirmation, capability ceilings, compatibility mode, revocation and
  audit. Typed Workspace API in the plugin SDK.
- Processor tool configuration: workspace operations, event and bot tools,
  default tool sets for new Agents and Pipelines, and sensitive-tool
  warnings.
- Plugin permission picker in the WebUI; LocalAgent declares every
  plugin-callable permission.
- Documentation for plugin permissions and the Workspace API in English,
  Chinese and Japanese.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 16:36:22 +08:00

51 lines
1.8 KiB
Python

"""Database fixture for plugin persistence behavior tests."""
import os
import pytest
from sqlalchemy import text
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from langbot.pkg.entity.persistence.base import Base
from langbot.pkg.entity.persistence.bstorage import BinaryStorage
from langbot.pkg.entity.persistence.plugin import PluginSetting
from langbot.pkg.entity.persistence.user import User
from langbot.pkg.entity.persistence.workspace import Workspace
from langbot_plugin.runtime.security import PLUGIN_FILE_STORAGE_DIR_ENV
@pytest.fixture(autouse=True)
def clean_file_transfer_env():
original = os.environ.get(PLUGIN_FILE_STORAGE_DIR_ENV)
yield
if original is None:
os.environ.pop(PLUGIN_FILE_STORAGE_DIR_ENV, None)
else:
os.environ[PLUGIN_FILE_STORAGE_DIR_ENV] = original
@pytest.fixture
async def plugin_db():
engine = create_async_engine('sqlite+aiosqlite:///:memory:')
try:
async with engine.begin() as connection:
await connection.execute(text('PRAGMA foreign_keys=ON'))
await connection.run_sync(
Base.metadata.create_all,
tables=[User.__table__, Workspace.__table__, PluginSetting.__table__, BinaryStorage.__table__],
)
async with AsyncSession(engine, expire_on_commit=False) as session:
session.add_all(
Workspace(
uuid=workspace,
instance_uuid='instance-a',
name=workspace,
slug=workspace,
source='cloud_projection',
)
for workspace in ('workspace-a', 'workspace-b')
)
await session.flush()
yield session
finally:
await engine.dispose()