Files
clide/legacy/tests/unit/test_extensions.py
T
jpmschweitzerandClaude Opus 4.7 a355751437 move python clide to legacy/
Clide is being rebuilt as a Flutter desktop app. The Python Textual
implementation moves wholesale into legacy/ rather than being deleted:
its pane model, panel set, git skills, and panel communication design
are real thought that should remain readable next to the new code
while the rebuild finds its shape. Git's rename tracking preserves
history, so `git log -- legacy/` still works.

The Flutter rebuild lives at the repo root alongside a Go sidecar
(the architecture claudian was heading toward, which folds into
clide as a core component rather than a separate plugin project).
Bootstrap of the new shape lands in subsequent commits.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 20:30:51 +02:00

53 lines
1.5 KiB
Python

"""Tests for extension system."""
import pytest
from clide.extensions import hookimpl
from clide.extensions.manager import ExtensionManager
class SampleExtension:
"""Sample extension for testing."""
@hookimpl
def clide_on_app_startup(self, app: object) -> None:
"""Track that startup was called."""
self.startup_called = True
self.received_app = app
class TestExtensionManager:
"""Tests for ExtensionManager."""
def test_register_plugin(self) -> None:
"""Plugins can be registered manually."""
manager = ExtensionManager()
extension = SampleExtension()
manager.register_plugin(extension, "sample")
assert "sample" in manager.list_extensions()
def test_unregister_plugin(self) -> None:
"""Plugins can be unregistered."""
manager = ExtensionManager()
extension = SampleExtension()
manager.register_plugin(extension, "sample")
manager.unregister_plugin("sample")
assert "sample" not in manager.list_extensions()
@pytest.mark.asyncio
async def test_trigger_startup_hook(self) -> None:
"""Startup hooks are triggered for all extensions."""
manager = ExtensionManager()
extension = SampleExtension()
manager.register_plugin(extension, "sample")
mock_app = object()
await manager.trigger_app_startup(mock_app)
assert extension.startup_called is True
assert extension.received_app is mock_app