Files
manual_slop/tests/test_gui2_events.py

26 lines
911 B
Python

import pytest
from unittest.mock import patch, MagicMock
from src.gui_2 import App
from src import ai_client
@pytest.fixture
def app_instance(monkeypatch: pytest.MonkeyPatch) -> type[App]:
"""Fixture to provide the App class with necessary environment variables."""
monkeypatch.setenv("SLOP_TEST_HOOKS", "1")
return App
def test_app_subscribes_to_events(app_instance: type[App]) -> None:
"""
This test checks that the App's __init__ method subscribes the necessary
event handlers to the ai_client.events emitter.
"""
with patch.object(ai_client.events, 'on') as mock_on:
app = app_instance()
mock_on.assert_called()
calls = mock_on.call_args_list
event_names = [call.args[0] for call in calls]
assert "request_start" in event_names
assert "response_received" in event_names
assert "tool_execution" in event_names
# We don't check for __self__ anymore as they might be lambdas