working the player
This commit is contained in:
47
tests/test_timeline.py
Normal file
47
tests/test_timeline.py
Normal file
@@ -0,0 +1,47 @@
|
||||
"""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))
|
||||
Reference in New Issue
Block a user