Files
qwenpaw/tests/unit/app/test_agents_workspace_initialization.py
agent-radar 1a3a4ccde1
Creator App Tests / PR Spam Gate (push) Skipped
Frontend Tests / PR Spam Gate (push) Skipped
NPM Format (website & console) / PR Spam Gate (push) Skipped
Pre-commit Checks / PR Spam Gate (push) Skipped
QwenPaw Creator Plugin Release / check-version (push) Canceled after 0s
QwenPaw Creator Plugin Release / upload-oss (push) Canceled after 0s
Tests / PR Spam Gate (push) Skipped
CodeQL / CodeQL (python) (push) Canceled after 0s
CodeQL / CodeQL (typescript) (push) Canceled after 0s
Creator App Tests / Creator Backend Tests (push) Canceled after 0s
Creator App Tests / Creator UI Build & Tests (push) Canceled after 0s
E2E Smoke Tests / Playwright UI Smoke (push) Canceled after 0s
Frontend Tests / Detect console changes (push) Canceled after 0s
NPM Format (website & console) / website format check (push) Canceled after 0s
NPM Format (website & console) / console format check (push) Canceled after 0s
Pre-commit Checks / Pre-commit (push) Canceled after 0s
QwenPaw Data Plugin Release / check-version (push) Canceled after 0s
Tests / Detect code changes (push) Canceled after 0s
Frontend Tests / Vitest Unit Tests (push) Canceled after 0s
Frontend Tests / Frontend Summary (push) Canceled after 0s
QwenPaw Data Plugin Release / upload-oss (push) Canceled after 0s
Tests / Maintainer Approval (push) Canceled after 0s
Tests / Unit Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - fallback (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p2 (push) Canceled after 0s
Tests / Coverage Report (push) Canceled after 0s
Tests / Test Summary (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:01:50 +08:00

92 lines
2.4 KiB
Python

# -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Regression tests for agent workspace initialization."""
import json
from pathlib import Path
from types import SimpleNamespace
from qwenpaw.app.routers import agents as agents_router
def _stub_global_config(language: str = "en") -> SimpleNamespace:
return SimpleNamespace(
agents=SimpleNamespace(language=language),
)
def test_initialize_agent_workspace_creates_runtime_compatible_files(
monkeypatch,
tmp_path,
):
"""New workspaces should match the runtime file contract."""
import qwenpaw.config as config_module
monkeypatch.setattr(
config_module,
"load_config",
lambda: _stub_global_config("en"),
)
monkeypatch.setattr(
agents_router,
"_install_initial_skills",
lambda workspace_dir, skill_names: None,
)
agents_router._initialize_agent_workspace(tmp_path)
assert (tmp_path / "sessions").is_dir()
assert (tmp_path / "memory").is_dir()
assert (tmp_path / "skills").is_dir()
assert not (tmp_path / "active_skills").exists()
assert not (tmp_path / "customized_skills").exists()
assert json.loads(
(tmp_path / "jobs.json").read_text(encoding="utf-8"),
) == {
"version": 1,
"jobs": [],
}
assert json.loads(
(tmp_path / "chats.json").read_text(encoding="utf-8"),
) == {
"version": 1,
"chats": [],
}
def test_initialize_agent_workspace_applies_md_template_with_language(
monkeypatch,
tmp_path,
):
"""Workspace initialization should pass language and md_template_id."""
import qwenpaw.config as config_module
recorded_calls: list[tuple[str, Path, str | None]] = []
monkeypatch.setattr(
config_module,
"load_config",
lambda: _stub_global_config("ru"),
)
monkeypatch.setattr(
agents_router,
"copy_workspace_md_files",
lambda language, workspace_dir, md_template_id=None: (
recorded_calls.append(
(language, workspace_dir, md_template_id),
)
),
)
monkeypatch.setattr(
agents_router,
"_install_initial_skills",
lambda workspace_dir, skill_names: None,
)
agents_router._initialize_agent_workspace(
tmp_path,
md_template_id="qa",
)
assert recorded_calls == [("ru", tmp_path, "qa")]