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.

926 B
Raw Blame
"""ContactChanged event contract: frozen, defaults, action vocabulary parity."""
from __future__ import annotations

import dataclasses

import pytest

from dodaios.contacts.notify import CONTACT_CHANGE_ACTIONS
from dodaios.core.events import ContactChanged, Event


def test_contact_changed_is_frozen_event_with_trace():
    evt = ContactChanged(action="created", slug="chris", name="Chris")
    assert isinstance(evt, Event)
    assert evt.trace_id is not None
    assert evt.timestamp_ns > 0
    with pytest.raises(dataclasses.FrozenInstanceError):
        evt.slug = "other"  # type: ignore[misc]


def test_contact_changed_action_vocabulary_documented():
    # The docstring names the owning vocabulary so the two sites cannot drift
    # silently — and the canonical actions construct cleanly.
    for action in CONTACT_CHANGE_ACTIONS:
        assert ContactChanged(action=action, slug="s", name="N").action == action