This commit is contained in:
Samir Hanna Verza 2026-10-14 13:04:11 +00:00 • committed by GitHub
commit 15729af614
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 1 deletions

View file

@ -4,6 +4,9 @@ from __future__ import annotations
import pytest
from strix.config import loader
from strix.interface import platform_identity
@pytest.fixture(autouse=True)
def _isolate_mcp_config(
@ -26,6 +29,24 @@ def _isolate_mcp_config(
monkeypatch.delenv("STRIX_MCP_EXCLUDE", raising=False)
@pytest.fixture(autouse=True)
def _isolate_user_state(
monkeypatch: pytest.MonkeyPatch, tmp_path_factory: pytest.TempPathFactory
) -> None:
"""Keep the suite from writing the developer's real ``~/.strix`` files.
Code the tests drive persists the CLI config and the device identity at paths
that are fixed when the modules are imported (``Path.home()`` at import time),
so setting ``HOME`` per test is too late for them. Without this, running the
suite replaces ``~/.strix/cli-config.json`` (the stored model, API key and API
base) and ``~/.strix/cli-identity.json`` with whatever the last test wrote.
Tests that exercise these paths set their own after this runs.
"""
state = tmp_path_factory.mktemp("strix-user-state")
monkeypatch.setattr(loader, "_DEFAULT_PATH", state / "cli-config.json")
monkeypatch.setattr(platform_identity, "IDENTITY_PATH", state / "cli-identity.json")
@pytest.fixture(autouse=True)
def _plain_terminal(monkeypatch: pytest.MonkeyPatch) -> None:
"""Make Rich output identical on every developer's machine.

View file

@ -17,10 +17,19 @@ import requests
from rich.console import Console
from strix.interface import cloud, platform_cli
from strix.interface.cloud import http, render, runner, workspaces
from strix.interface.cloud import billing, http, render, runner, workspaces
from strix.interface.cloud.spec import GROUP_HELP, SPEC
@pytest.fixture(autouse=True)
def _wallet_cache_in_tmp(
monkeypatch: pytest.MonkeyPatch, tmp_path_factory: pytest.TempPathFactory
) -> None:
"""Keep the top-up flow's npm cache (``~/.strix/wallet-npm-cache``) out of the real home."""
cache = tmp_path_factory.mktemp("wallet-npm-cache")
monkeypatch.setattr(billing, "_wallet_npm_cache", lambda: cache)
class FakeResponse:
def __init__(
self,

View file

@ -68,8 +68,10 @@ def test_scan_ended_reports_resumed_usage_delta(
@pytest.mark.parametrize("telemetry", [posthog, scarf])
def test_scan_ended_reports_all_fresh_run_usage(
telemetry: Any,
tmp_path: Any,
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.chdir(tmp_path) # a run directory is created under ./strix_runs
state = ReportState()
state.record_sdk_usage(
agent_id="agent",