working the player

This commit is contained in:
2026-04-01 19:23:17 -03:00
parent 68802db15c
commit 0f7e4424bc
13 changed files with 1013 additions and 571 deletions

38
tests/test_tracker.py Normal file
View File

@@ -0,0 +1,38 @@
"""Tests for cht.stream.tracker — RecordingTracker."""
import time
from pathlib import Path
from unittest.mock import patch, MagicMock
import pytest
from cht.stream.tracker import RecordingTracker
class TestRecordingTracker:
def test_initial_duration_is_zero(self, tmp_path):
tracker = RecordingTracker(tmp_path / "rec.ts")
assert tracker.duration == 0.0
def test_callback_called_on_update(self, tmp_path):
rec = tmp_path / "rec.ts"
rec.write_bytes(b"\x00" * 100_000)
cb = MagicMock()
tracker = RecordingTracker(rec, on_duration_update=cb)
with patch.object(tracker, "_probe_duration", return_value=10.0):
tracker.start()
time.sleep(3)
tracker.stop()
cb.assert_called()
assert cb.call_args[0][0] > 0
def test_no_callback_if_file_missing(self, tmp_path):
cb = MagicMock()
tracker = RecordingTracker(tmp_path / "nonexistent.ts", on_duration_update=cb)
tracker.start()
time.sleep(3)
tracker.stop()
cb.assert_not_called()