Files
qwenpaw/tests/unit/harnesses/test_qoder_discovery.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

130 lines
3.3 KiB
Python

# -*- coding: utf-8 -*-
"""Tests for cross-platform Qoder CLI discovery."""
from __future__ import annotations
from pathlib import Path
import pytest
# pylint: disable=wrong-import-position
# flake8: noqa: E402,E501
pytest.importorskip(
"qoder_agent_sdk",
reason=(
"importing qwenpaw.harnesses.qoder eagerly imports the optional "
"qoder_agent_sdk (qoder extra)"
),
)
from qwenpaw.harnesses.qoder.discovery import (
default_install_candidates,
resolve_qoder_binary_info,
)
def _executable(path: Path) -> Path:
path.parent.mkdir(parents=True)
path.touch()
path.chmod(path.stat().st_mode | 0o111)
return path
def test_prefers_explicit_qoder_binary(tmp_path: Path) -> None:
binary = _executable(tmp_path / "custom" / "qodercli")
bundled = _executable(tmp_path / "sdk" / "qodercli")
resolution = resolve_qoder_binary_info(
str(binary),
sdk_candidate=bundled,
install_candidates=[],
)
assert resolution is not None
assert resolution.path == binary
assert resolution.source == "configured"
def test_reads_official_qodercli_environment_path(
tmp_path: Path,
) -> None:
binary = _executable(tmp_path / "environment" / "qodercli")
resolution = resolve_qoder_binary_info(
environ={"QODERCLI_PATH": str(binary)},
sdk_candidate=tmp_path / "missing",
install_candidates=[],
)
assert resolution is not None
assert resolution.path == binary
assert resolution.source == "environment"
def test_prefers_python_sdk_bundled_cli(tmp_path: Path) -> None:
binary = _executable(tmp_path / "sdk" / "qodercli")
resolution = resolve_qoder_binary_info(
environ={},
sdk_candidate=binary,
install_candidates=[],
)
assert resolution is not None
assert resolution.path == binary
assert resolution.source == "python-sdk"
def test_invalid_manual_binary_does_not_fall_back(
tmp_path: Path,
) -> None:
bundled = _executable(tmp_path / "sdk" / "qodercli")
resolution = resolve_qoder_binary_info(
str(tmp_path / "missing" / "qodercli"),
sdk_candidate=bundled,
install_candidates=[],
)
assert resolution is None
def test_windows_candidates_include_npm_and_standalone_paths(
tmp_path: Path,
) -> None:
candidates = default_install_candidates(
tmp_path,
platform_name="win32",
environ={
"APPDATA": str(tmp_path / "AppData" / "Roaming"),
"LOCALAPPDATA": str(tmp_path / "AppData" / "Local"),
},
)
paths = {path for path, _ in candidates}
npm_binary = tmp_path / "AppData" / "Roaming" / "npm" / "qodercli.cmd"
standalone_binary = (
tmp_path / "AppData" / "Local" / "Programs" / "Qoder" / "qodercli.exe"
)
assert npm_binary in paths
assert standalone_binary in paths
def test_windows_executable_does_not_require_posix_mode(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setenv("PATH", "")
binary = tmp_path / "qodercli.exe"
binary.touch()
resolution = resolve_qoder_binary_info(
platform_name="win32",
environ={},
sdk_candidate=tmp_path / "missing.exe",
install_candidates=[(binary, "standalone")],
)
assert resolution is not None
assert resolution.path == binary