Install and update artemis-use with task diagnostics and plugin guidance. Preserve cross-device file receipts, review canonical reports, guard stage transitions and reduce small history summaries. Improve exploration lifecycle, request recovery and browser live connections.
93 lines
3.4 KiB
Python
93 lines
3.4 KiB
Python
# Copyright 2026 Google LLC
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
"""Repository-wide pytest fixtures and classification helpers.
|
|
|
|
The default test paths contain only deterministic tests. Tests under the
|
|
integration and end-to-end trees remain directly runnable, and receive stable
|
|
markers here so callers can select them without relying on filename patterns.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from artemis.drivers.mock.mock_driver import MockDeviceDriver
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def no_host_adb_discovery(monkeypatch, request):
|
|
"""Deterministic tests must never connect to host emulators or remembered phones."""
|
|
from artemis.runtime.adb_discovery import adb_device_discovery
|
|
|
|
if any(
|
|
request.node.get_closest_marker(name)
|
|
for name in ("android", "integration", "e2e", "manual")
|
|
):
|
|
return
|
|
monkeypatch.setattr(adb_device_discovery, "refresh", lambda *args, **kwargs: [])
|
|
monkeypatch.setattr(adb_device_discovery, "remember", lambda *args: True)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_driver():
|
|
"""Provide an isolated mock mobile driver."""
|
|
return MockDeviceDriver(device_id="fixture-mock-device", width=1080, height=2400)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def no_host_data_engine_ipc(monkeypatch, tmp_path, request):
|
|
"""Unit-test events must not reach a user's running desktop queue.
|
|
|
|
The reconnect path also reads a port file, so overriding the inherited
|
|
environment port alone does not isolate tests. IPC tests can explicitly
|
|
override these discovery functions with their own endpoints or mocks.
|
|
"""
|
|
if any(
|
|
request.node.get_closest_marker(name)
|
|
for name in ("android", "integration", "e2e", "manual")
|
|
):
|
|
return
|
|
monkeypatch.setattr("artemis.data_engine.engine.read_ipc_port", lambda: None)
|
|
monkeypatch.setattr(
|
|
"artemis.data_engine.engine.get_ipc_port_file", lambda: tmp_path / "no-host-ipc"
|
|
)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def isolated_plugin_registry(monkeypatch, tmp_path, request):
|
|
"""Unit tests never load or mutate the user's installed plugins and credentials."""
|
|
if any(
|
|
request.node.get_closest_marker(name)
|
|
for name in ("android", "integration", "e2e", "manual")
|
|
):
|
|
return
|
|
monkeypatch.setattr("artemis.plugins.store.get_app_dir", lambda: tmp_path / "app")
|
|
|
|
|
|
def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
|
|
"""Attach test-layer markers according to the owning test directory."""
|
|
for item in items:
|
|
parts = Path(str(item.path)).parts
|
|
if "integration" in parts:
|
|
item.add_marker(pytest.mark.integration)
|
|
if "e2e" in parts:
|
|
item.add_marker(pytest.mark.e2e)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def no_host_codex_startup_sync(monkeypatch):
|
|
"""Starting an isolated test app must never modify the real Codex profile."""
|
|
monkeypatch.setenv("ARTEMIS_SKIP_CODEX_SYNC", "1")
|