Advanced — Aquilia Documentation
Comprehensive guide and documentation for Advanced in the Aquilia framework. View API reference, examples, and implementation patterns.
Dependency Injection / Advanced Advanced DI & Testing Overrides Customize the resolution graph dynamically, swap providers at runtime during tests, and configure complex factory pipelines. Decorators Cheat Sheet Decorator Scope Description , , , , , , ].map((row, i) => ( ))} TestRegistry Overrides Swap components with mock implementations during unit or integration testing: from aquilia.di import TestRegistry, MockProvider # Create a test registry delegating to production setup test_reg = TestRegistry(base=production_registry) # Override with custom value or MockProvider test_reg.override(EmailService, MockProvider( send=AsyncMock(return_value=True) )) # Override database connection pools with mock mocks test_reg.override(DatabasePool, value=FakeDbPool()) Pytest Fixtures Use the built-in context overrides helper to automatically mock out components during test execution: import pytest from aquilia.di.testing import override_container @pytest.mark.asyncio async def test_user_creation(client, app_container): # Override UserService inside the app DI container temporarily: mock_service = MagicMock() with override_container(app_container, ): response = await client.post("/users", json= ) assert response.status_code == 201 mock_service.create.assert_called_once() Scopes Models )
Go to Homepage