fixed some tests

This commit is contained in:
2025-11-15 16:56:12 +01:00
parent f49598d82b
commit fac0cecf90
13 changed files with 10434 additions and 3301 deletions

View File

@@ -338,7 +338,8 @@ class TestProgressService:
@pytest.mark.asyncio
async def test_broadcast_callback(self, service, mock_broadcast):
"""Test broadcast callback is invoked correctly."""
service.set_broadcast_callback(mock_broadcast)
# Subscribe to progress_updated events
service.subscribe("progress_updated", mock_broadcast)
await service.start_progress(
progress_id="test-1",
@@ -348,15 +349,18 @@ class TestProgressService:
# Verify callback was called for start
mock_broadcast.assert_called_once()
call_args = mock_broadcast.call_args
assert call_args[1]["message_type"] == "download_progress"
assert call_args[1]["room"] == "download_progress"
assert "test-1" in str(call_args[1]["data"])
# First positional arg is ProgressEvent
call_args = mock_broadcast.call_args[0][0]
assert call_args.event_type == "download_progress"
assert call_args.room == "download_progress"
assert call_args.progress_id == "test-1"
assert call_args.progress.id == "test-1"
@pytest.mark.asyncio
async def test_broadcast_on_update(self, service, mock_broadcast):
"""Test broadcast on progress update."""
service.set_broadcast_callback(mock_broadcast)
# Subscribe to progress_updated events
service.subscribe("progress_updated", mock_broadcast)
await service.start_progress(
progress_id="test-1",
@@ -375,11 +379,15 @@ class TestProgressService:
# Should have been called
assert mock_broadcast.call_count >= 1
# First positional arg is ProgressEvent
call_args = mock_broadcast.call_args[0][0]
assert call_args.progress.current == 50
@pytest.mark.asyncio
async def test_broadcast_on_complete(self, service, mock_broadcast):
"""Test broadcast on progress completion."""
service.set_broadcast_callback(mock_broadcast)
# Subscribe to progress_updated events
service.subscribe("progress_updated", mock_broadcast)
await service.start_progress(
progress_id="test-1",
@@ -395,13 +403,15 @@ class TestProgressService:
# Should have been called
mock_broadcast.assert_called_once()
call_args = mock_broadcast.call_args
assert "completed" in str(call_args[1]["data"]).lower()
# First positional arg is ProgressEvent
call_args = mock_broadcast.call_args[0][0]
assert call_args.progress.status.value == "completed"
@pytest.mark.asyncio
async def test_broadcast_on_failure(self, service, mock_broadcast):
"""Test broadcast on progress failure."""
service.set_broadcast_callback(mock_broadcast)
# Subscribe to progress_updated events
service.subscribe("progress_updated", mock_broadcast)
await service.start_progress(
progress_id="test-1",
@@ -417,8 +427,9 @@ class TestProgressService:
# Should have been called
mock_broadcast.assert_called_once()
call_args = mock_broadcast.call_args
assert "failed" in str(call_args[1]["data"]).lower()
# First positional arg is ProgressEvent
call_args = mock_broadcast.call_args[0][0]
assert call_args.progress.status.value == "failed"
@pytest.mark.asyncio
async def test_clear_history(self, service):