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
73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Whether Computer Use reports itself usable, and on what grounds.
|
|
|
|
The desktop shell offers a control endpoint on every platform it runs on, but
|
|
the native helper is built only for Windows and macOS. Treating the endpoint as
|
|
the whole answer registered the tool on Linux, where every call could do
|
|
nothing
|
|
but report the runtime unavailable.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from qwenpaw.app.computer_use import runtime as runtime_module
|
|
from qwenpaw.app.computer_use.runtime import HostRuntimeProvider, RuntimeStatus
|
|
|
|
_CONTROL_ENV = {
|
|
"QWENPAW_COMPUTER_USE_CONTROL_HOST": "127.0.0.1",
|
|
"QWENPAW_COMPUTER_USE_CONTROL_PORT": "51234",
|
|
"QWENPAW_COMPUTER_USE_CONTROL_TOKEN": "token",
|
|
}
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _reachable_host(monkeypatch: pytest.MonkeyPatch):
|
|
"""Present a reachable desktop host, so only the platform varies."""
|
|
for name, value in _CONTROL_ENV.items():
|
|
monkeypatch.setenv(name, value)
|
|
monkeypatch.setattr(HostRuntimeProvider, "_capability", None)
|
|
yield
|
|
monkeypatch.setattr(HostRuntimeProvider, "_capability", None)
|
|
|
|
|
|
@pytest.mark.parametrize("platform", ["win32", "darwin"])
|
|
def test_a_platform_with_a_helper_is_available(
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
platform: str,
|
|
) -> None:
|
|
monkeypatch.setattr(runtime_module.sys, "platform", platform)
|
|
status = HostRuntimeProvider.status()
|
|
assert status == RuntimeStatus(
|
|
supported_platform=True,
|
|
host_reachable=True,
|
|
)
|
|
assert HostRuntimeProvider.is_available() is True
|
|
|
|
|
|
@pytest.mark.parametrize("platform", ["linux", "freebsd"])
|
|
def test_a_platform_without_a_helper_is_not_available(
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
platform: str,
|
|
) -> None:
|
|
monkeypatch.setattr(runtime_module.sys, "platform", platform)
|
|
status = HostRuntimeProvider.status()
|
|
# The host is reachable, and that used to be the entire test.
|
|
assert status.host_reachable is True
|
|
assert status.supported_platform is False
|
|
assert HostRuntimeProvider.is_available() is False
|
|
|
|
|
|
def test_a_supported_platform_without_a_host_is_not_available(
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
) -> None:
|
|
"""Reported apart, so a caller can say which precondition is missing."""
|
|
monkeypatch.setattr(runtime_module.sys, "platform", "win32")
|
|
for name in _CONTROL_ENV:
|
|
monkeypatch.delenv(name, raising=False)
|
|
status = HostRuntimeProvider.status()
|
|
assert status.supported_platform is True
|
|
assert status.host_reachable is False
|
|
assert HostRuntimeProvider.is_available() is False
|