Files
qwenpaw/tests/integration/test_mcp_drivers_module.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

132 lines
3.7 KiB
Python

# -*- coding: utf-8 -*-
"""Integration tests for MCP & Drivers module internals.
Covers src/qwenpaw/agents/acp/* and src/qwenpaw/drivers/* (module
level, 1,962 uncovered lines): acp service helpers, credentials
providers, driver types.
"""
from __future__ import annotations
import asyncio
import pytest
# ------------------------------------------------------------------ #
# acp service helpers
# ------------------------------------------------------------------ #
@pytest.mark.integration
@pytest.mark.p1
def test_acp_resolve_process_command_found() -> None:
"""_resolve_process_command resolves an existing binary via PATH."""
from qwenpaw.agents.acp.service import _resolve_process_command
import os
resolved = _resolve_process_command("python3", dict(os.environ))
lowered = resolved.lower()
assert (
lowered.endswith("python3")
or lowered.endswith("python3.exe")
or "/" in resolved
or "\\" in resolved
)
@pytest.mark.integration
@pytest.mark.p1
def test_acp_resolve_process_command_missing() -> None:
"""_resolve_process_command falls back to the raw command."""
from qwenpaw.agents.acp.service import _resolve_process_command
resolved = _resolve_process_command(
"integ-nonexistent-binary",
{"PATH": "/nonexistent"},
)
assert resolved == "integ-nonexistent-binary"
@pytest.mark.integration
@pytest.mark.p1
def test_acp_kill_process_tree_noop() -> None:
"""_kill_process_tree tolerates a dead pid."""
from qwenpaw.agents.acp.service import _kill_process_tree
# pid 0 / negative are invalid; use a large unlikely pid
_kill_process_tree(999999999)
# ------------------------------------------------------------------ #
# credentials providers
# ------------------------------------------------------------------ #
@pytest.mark.integration
@pytest.mark.p1
def test_none_provider_resolves_empty() -> None:
"""NoneProvider resolves to an empty credential."""
from qwenpaw.drivers.credentials.providers import NoneProvider
provider = NoneProvider()
cred = asyncio.run(provider.resolve())
assert cred.kind == "none"
assert cred.secrets == {}
@pytest.mark.integration
@pytest.mark.p1
def test_resolved_credential_values_merge() -> None:
"""ResolvedCredential.values merges public and secrets."""
from qwenpaw.drivers.credentials.types import ResolvedCredential
cred = ResolvedCredential(
kind="token",
public={"user": "u"},
secrets={"token": "t"},
)
assert cred.values == {"user": "u", "token": "t"}
@pytest.mark.integration
@pytest.mark.p1
def test_is_transient_oauth_status() -> None:
"""_is_transient_oauth_status flags 429/503, not 401."""
import httpx
from qwenpaw.drivers.credentials.providers import (
_is_transient_oauth_status,
)
def _err(code):
request = httpx.Request("POST", "http://x")
response = httpx.Response(code, request=request)
return httpx.HTTPStatusError("e", request=request, response=response)
assert _is_transient_oauth_status(_err(429)) is True
assert _is_transient_oauth_status(_err(503)) is True
assert _is_transient_oauth_status(_err(401)) is False
# ------------------------------------------------------------------ #
# driver types
# ------------------------------------------------------------------ #
@pytest.mark.integration
@pytest.mark.p1
def test_driver_card_construct() -> None:
"""DriverCard builds with required fields and defaults."""
from qwenpaw.drivers.contracts import DriverCard
card = DriverCard(
name="integ-driver",
protocol="mcp",
endpoint={"command": "echo"},
)
assert card.name == "integ-driver"
assert card.enabled is True
assert not card.credentials