fix: plugin allowlist matching and windows session paths (#72)
This commit is contained in:
+16
-2
@@ -1,11 +1,17 @@
|
||||
from pathlib import Path
|
||||
from pathlib import Path, PureWindowsPath
|
||||
from unittest.mock import patch
|
||||
|
||||
import anyio
|
||||
import pytest
|
||||
|
||||
from takopi.model import ActionEvent, CompletedEvent, ResumeToken, StartedEvent
|
||||
from takopi.runners.pi import ENGINE, PiRunner, PiStreamState, translate_pi_event
|
||||
from takopi.runners.pi import (
|
||||
ENGINE,
|
||||
PiRunner,
|
||||
PiStreamState,
|
||||
_default_session_dir,
|
||||
translate_pi_event,
|
||||
)
|
||||
from takopi.schemas import pi as pi_schema
|
||||
|
||||
|
||||
@@ -152,3 +158,11 @@ def test_session_path_prefers_run_base_dir(tmp_path: Path) -> None:
|
||||
|
||||
default_session_dir.assert_called_once_with(project_cwd)
|
||||
assert str(session_root) in session_path
|
||||
|
||||
|
||||
def test_session_path_sanitizes_windows_separators() -> None:
|
||||
cwd = PureWindowsPath("C:\\foo\\bar")
|
||||
session_dir = _default_session_dir(cwd)
|
||||
name = session_dir.name
|
||||
assert "\\" not in name
|
||||
assert ":" not in name
|
||||
|
||||
@@ -97,6 +97,23 @@ def test_allowlist_filters_by_distribution(monkeypatch) -> None:
|
||||
assert ids == ["codex"]
|
||||
|
||||
|
||||
def test_allowlist_canonicalizes_distribution_names(monkeypatch) -> None:
|
||||
entrypoints = [
|
||||
FakeEntryPoint(
|
||||
"slack",
|
||||
"takopi.transport.slack:BACKEND",
|
||||
plugins.TRANSPORT_GROUP,
|
||||
dist_name="takopi-transport-slack",
|
||||
)
|
||||
]
|
||||
install_entrypoints(monkeypatch, entrypoints)
|
||||
|
||||
ids = plugins.list_ids(
|
||||
plugins.TRANSPORT_GROUP, allowlist=["takopi_transport.slack"]
|
||||
)
|
||||
assert ids == ["slack"]
|
||||
|
||||
|
||||
def test_validator_errors_are_captured(monkeypatch) -> None:
|
||||
entrypoints = [
|
||||
FakeEntryPoint(
|
||||
|
||||
Reference in New Issue
Block a user