mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-27 21:05:34 +00:00
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
"""Test fixtures for installer / cold-start refresh tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def tmp_openjarvis_home(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|
"""Point ``DEFAULT_CONFIG_DIR`` at a tmpdir for isolated tests.
|
|
|
|
Returns the directory; teardown is automatic via tmp_path.
|
|
"""
|
|
home = tmp_path / ".openjarvis"
|
|
home.mkdir()
|
|
(home / ".state").mkdir()
|
|
(home / ".state" / "models").mkdir()
|
|
(home / ".scripts").mkdir()
|
|
config_path = home / "config.toml"
|
|
monkeypatch.setattr("openjarvis.core.config.DEFAULT_CONFIG_DIR", home)
|
|
monkeypatch.setattr("openjarvis.core.config.DEFAULT_CONFIG_PATH", config_path)
|
|
# Also patch init_cmd's module-level bindings (imported with ``from ... import``).
|
|
monkeypatch.setattr("openjarvis.cli.init_cmd.DEFAULT_CONFIG_DIR", home)
|
|
monkeypatch.setattr("openjarvis.cli.init_cmd.DEFAULT_CONFIG_PATH", config_path)
|
|
# Patch doctor_cmd's module-level bindings.
|
|
monkeypatch.setattr("openjarvis.cli.doctor_cmd.DEFAULT_CONFIG_PATH", config_path)
|
|
monkeypatch.setenv("HOME", str(tmp_path))
|
|
return home
|