Skip to main content

Mocking

info

Learn how to use mocking in Fluvius Framework tests.

Mocking Dependencies

Mock External Services

from unittest.mock import AsyncMock, patch

@pytest.mark.asyncio
async def test_with_mocked_service():
with patch('myapp.services.email_service.send') as mock_send:
mock_send.return_value = True

# Test code that uses email_service
await aggregate.create_user('John', 'john@example.com')

# Verify mock was called
mock_send.assert_called_once()

Next Steps