Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/plugin-api-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
- name: Verify Steam v3 composition and migration
env:
AKASHIC_AGENT_ROOT: .akashic-core
AKASHIC_PLUGIN_FIXTURE_PYTHON: ${{ github.workspace }}/mcp/.venv/bin/python
PYTHONPATH: .akashic-core:mcp:mcp/.venv/lib/python3.13/site-packages
run: mcp/.venv/bin/python -m pytest -q mcp/tests tests
- name: Check changed v3 sources
Expand Down
2 changes: 1 addition & 1 deletion context_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from agent.lifecycle.types import BeforeTurnCtx
from agent.plugin_composition import HealthHandle, PluginTimers

from steam_runtime import backend
from .steam_runtime import backend


class SteamContextRuntime:
Expand Down
2 changes: 1 addition & 1 deletion plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
McpServerDefinition,
)

from context_source import SteamContextRuntime
from .context_source import SteamContextRuntime


class SteamConfig(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion steam_runtime/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from urllib.parse import urlencode
from urllib.request import urlopen

from steam_runtime.config import SteamRuntimeConfig, load_runtime_config
from .config import SteamRuntimeConfig, load_runtime_config


_DB_NAME = "steam_proactive.sqlite3"
Expand Down
12 changes: 12 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from __future__ import annotations

import sys
from pathlib import Path
from types import ModuleType


repo_root = Path(__file__).resolve().parents[1]
package = ModuleType("steam_test_plugin")
package.__path__ = [str(repo_root)]
package.__package__ = "steam_test_plugin"
sys.modules["steam_test_plugin"] = package
4 changes: 2 additions & 2 deletions tests/test_context_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from agent.control.timer import TimerReceipt, TimerStatus
from agent.lifecycle.types import BeforeTurnCtx
from agent.plugin_composition import PluginTimers
from context_source import SteamContextRuntime
from steam_runtime import backend
from steam_test_plugin.context_source import SteamContextRuntime # pyright: ignore[reportMissingImports]
from steam_test_plugin.steam_runtime import backend # pyright: ignore[reportMissingImports]


class _TimerHandle:
Expand Down
34 changes: 31 additions & 3 deletions tests/test_manager_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import asyncio
import hashlib
import json
import os
import shutil
import sqlite3
import sys
from datetime import UTC, datetime
from pathlib import Path

Expand Down Expand Up @@ -71,8 +71,9 @@ async def _eventually(predicate) -> None:


def _stage_plugin(tmp_path: Path) -> Path:
"""复制真实 Steam 插件并复用当前测试解释器。"""
"""复制真实 Steam 插件并链接调用方声明的 artifact 运行时。"""

runtime = Path(os.environ["AKASHIC_PLUGIN_FIXTURE_PYTHON"]).parent.parent
source = tmp_path / "plugins" / "steam"
shutil.copytree(
ROOT,
Expand All @@ -87,11 +88,38 @@ def _stage_plugin(tmp_path: Path) -> Path:
"tests",
),
)
runtime = Path(sys.executable).parent.parent
(source / "mcp" / ".venv").symlink_to(runtime, target_is_directory=True)
return source


def test_stage_plugin_links_declared_fixture_runtime(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
runtime = tmp_path / "artifact" / ".venv"
fixture_python = runtime / "bin" / "python"
fixture_python.parent.mkdir(parents=True)
fixture_python.touch()
monkeypatch.setenv("AKASHIC_PLUGIN_FIXTURE_PYTHON", str(fixture_python))

source = _stage_plugin(tmp_path)

assert (source / "mcp" / ".venv").readlink() == runtime


def test_stage_plugin_requires_fixture_python(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.delenv("AKASHIC_PLUGIN_FIXTURE_PYTHON", raising=False)

with pytest.raises(KeyError) as error:
_stage_plugin(tmp_path)

assert error.value.args == ("AKASHIC_PLUGIN_FIXTURE_PYTHON",)
assert not (tmp_path / "plugins").exists()


def _config(data_root: Path) -> Path:
data_root.mkdir(parents=True, exist_ok=True)
path = data_root / "steam_mcp_config.json"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from pathlib import Path
from typing import cast

import plugin
import pytest
from steam_test_plugin import plugin # pyright: ignore[reportMissingImports]
from agent.control.timer import OneShotTimer
from agent.plugin_composition import (
MCP_SERVERS,
Expand Down
Loading