Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

1.7 KB
Raw Blame
"""Shared fixtures for Phase-6 mission tests."""
from __future__ import annotations

from pathlib import Path

import pytest

from dodaios.missions.events import EventEnvelope, MissionDispatched, now_ms
from dodaios.missions.ids import uuid7_str


@pytest.fixture(autouse=True)
def _no_live_subscription_login(monkeypatch: pytest.MonkeyPatch) -> None:
    """Never read the developer's real ``claude`` / codex login to decide
    whether this is a subscription install (dodaios/missions/capacity.py): a
    signed-in machine would flip every mission test into the pinned path.
    Tests that need a subscription install set the sticky marker or patch
    ``install_is_pinned`` explicitly."""
    from dodaios.missions import init as mission_init

    monkeypatch.setattr(mission_init, "_positive_subscription_login", lambda: False)


@pytest.fixture
def tmp_missions_db(tmp_path: Path) -> Path:
    """Pfad zu einer frischen, leeren missions.db im tmp-Verzeichnis."""
    return tmp_path / "missions.db"


@pytest.fixture
def fake_mission_id() -> str:
    """Uniform mission ID for tests that don't check uuid7 properties."""
    return uuid7_str()


@pytest.fixture
def make_envelope():
    """Factory for an EventEnvelope with a MissionDispatched default payload."""

    def _build(
        *,
        mission_id: str | None = None,
        prompt: str = "test mission",
        source_actor: str = "hauptjarvis",
    ) -> EventEnvelope:
        return EventEnvelope(
            mission_id=mission_id or uuid7_str(),
            source_actor=source_actor,  # type: ignore[arg-type]
            ts_ms=now_ms(),
            payload=MissionDispatched(prompt=prompt),
        )

    return _build