Files
mitus/tests/test_timeline.py
2026-04-01 19:23:17 -03:00

48 lines
1.3 KiB
Python

"""Tests for cht.ui.timeline — Timeline state machine."""
import pytest
from unittest.mock import MagicMock
# Skip GTK import for headless testing
import sys
from unittest.mock import MagicMock as _MM
# Mock gi modules for headless testing
gi_mock = _MM()
gi_mock.require_version = _MM()
gtk_mock = _MM()
gobject_mock = _MM()
# GObject.Object needs __gsignals__ support
class FakeGObject:
def __init__(self):
self._signals = {}
def emit(self, signal, *args):
for cb in self._signals.get(signal, []):
cb(self, *args)
def connect(self, signal, cb):
self._signals.setdefault(signal, []).append(cb)
# We test the logic, not the GTK widgets
# Import after mocking would be complex, so test the state logic directly
try:
from cht.ui.timeline import State
HAS_GI = True
except ImportError:
HAS_GI = False
@pytest.mark.skipif(not HAS_GI, reason="GTK/gi not available")
class TestTimelineState:
def test_initial_state(self):
assert State.WAITING.name == "WAITING"
assert State.LIVE.name == "LIVE"
assert State.PLAYING.name == "PLAYING"
assert State.PAUSED.name == "PAUSED"
def test_state_values_are_unique(self):
values = [s.value for s in State]
assert len(values) == len(set(values))