Files
syndarix/backend/tests/api/dependencies/test_event_bus.py
Felipe Cardoso 664415111a test(backend): add comprehensive tests for OAuth and agent endpoints
- Added tests for OAuth provider admin and consent endpoints covering edge cases.
- Extended agent-related tests to handle incorrect project associations and lifecycle state transitions.
- Introduced tests for sprint status transitions and validation checks.
- Improved multiline formatting consistency across all test functions.
2026-01-03 01:44:11 +01:00

40 lines
1.2 KiB
Python

# tests/api/dependencies/test_event_bus.py
"""Tests for the event_bus dependency."""
from unittest.mock import AsyncMock, patch
import pytest
from app.api.dependencies.event_bus import get_event_bus
from app.services.event_bus import EventBus
@pytest.mark.asyncio
class TestGetEventBusDependency:
"""Tests for the get_event_bus FastAPI dependency."""
async def test_get_event_bus_returns_event_bus(self):
"""Test that get_event_bus returns an EventBus instance."""
mock_event_bus = AsyncMock(spec=EventBus)
with patch(
"app.api.dependencies.event_bus._get_connected_event_bus",
return_value=mock_event_bus,
):
result = await get_event_bus()
assert result is mock_event_bus
async def test_get_event_bus_calls_get_connected_event_bus(self):
"""Test that get_event_bus calls the underlying function."""
mock_event_bus = AsyncMock(spec=EventBus)
mock_get_connected = AsyncMock(return_value=mock_event_bus)
with patch(
"app.api.dependencies.event_bus._get_connected_event_bus",
mock_get_connected,
):
await get_event_bus()
mock_get_connected.assert_called_once()