Orchestrata Ultimate › Tests › Reference › test_di
Tests reference — tests/test_di.py
Module of tests, split out because the directory page would be too large.
Prose pending.
tests/test_di.py
source · 67 tests · 1099 lines
Tests for orchestrata_ultimate.di — Dependency Injection container.
Covers: core.protocols.base, di.container, core.interfaces/ (package)
| Kind | Name | Line | Description |
|---|---|---|---|
| function | test_container_register_and_resolve |
142 | |
| function | test_container_resolve_returns_correct_type |
149 | |
| function | test_container_register_instance |
155 | |
| function | test_container_register_instance_is_same_object |
162 | |
| function | test_container_singleton_scope_returns_same_instance |
170 | |
| function | test_container_transient_scope_returns_new_instance |
177 | |
| function | test_container_resolve_unregistered_raises |
184 | |
| function | test_container_multiple_registrations |
189 | |
| function | test_container_duplicate_registration_raises |
203 | |
| function | test_container_duplicate_with_override_allowed |
209 | |
| function | test_container_shutdown |
221 | shutdown() stops SINGLETON components resolved via resolve() — these |
| function | test_container_builder_basic |
236 | |
| function | test_container_builder_with_instance |
248 | |
| function | test_container_builder_with_config |
255 | |
| function | test_container_builder_multiple_components |
269 | |
| function | test_container_builder_singleton_in_builder |
286 | |
| function | test_container_registry_register |
304 | |
| function | test_container_registry_get |
310 | |
| function | test_container_registry_get_missing_raises |
317 | |
| function | test_container_registry_isolation |
323 | |
| function | test_component_registration_fields |
337 | |
| function | test_resolution_context_creation |
353 | |
| function | test_component_scope_values |
363 | |
| function | test_icomponent_cannot_instantiate_abstract |
374 | IComponent is abstract — direct instantiation raises TypeError. |
| function | test_icomponent_concrete_get_health |
380 | |
| function | test_icomponent_concrete_get_metadata |
386 | |
| function | test_icomponent_concrete_lifecycle |
392 | |
| function | test_validate_registration_factory_only |
407 | Factory-only registration passes validation. |
| function | test_validate_registration_neither_impl_nor_factory_raises |
413 | Registration without impl or factory raises ValueError. |
| function | test_validate_registration_impl_not_subclass |
421 | Implementation that doesn't implement interface raises ValueError. |
| function | test_register_instance_wrong_type_raises |
432 | register_instance with wrong type raises ValueError. |
| function | test_resolve_request_scope_caches_in_context |
443 | REQUEST scope with context_id stores in self._context for cache hit. |
| function | test_circular_dependency_in_resolve_with_context |
504 | Circular dependency detected in _resolve_with_context raises RecursionError. |
| function | test_circular_dependency_resolve_handler |
513 | resolve() catches RecursionError and raises RuntimeError. |
| function | test_factory_accepts_config |
534 | Factory that accepts config gets config passed. |
| function | test_factory_no_config_param |
548 | Factory without config param is called without args. |
| function | test_resolve_dependencies_with_context |
628 | Untyped param resolved from context. |
| function | test_resolve_dependencies_with_default |
637 | Param with default uses default when not in context. |
| function | test_resolve_dependencies_icomponent_param |
646 | IComponent-typed param is resolved from container. |
| function | test_resolve_dependencies_config_value |
683 | Param resolved from config using interface.name.lower().param_name pattern. |
| function | test_resolve_untyped_param_from_context |
695 | Untyped param resolved from context. |
| function | test_resolve_untyped_param_no_context_no_default |
725 | Untyped param without context or default raises ValueError. |
| function | test_extract_dependencies |
759 | _extract_dependencies finds IComponent-typed constructor params. |
| function | test_extract_dependencies_no_deps |
765 | _extract_dependencies returns empty list for no-deps class. |
| function | test_set_context_and_get_context |
776 | set_context stores value, get_context retrieves it. |
| function | test_get_context_default |
782 | get_context returns default for missing key. |
| function | test_get_context_missing_no_default |
787 | get_context returns None for missing key without default. |
| function | test_shutdown_error_suppressed |
821 | shutdown suppresses errors from component stop(). |
| function | test_get_registry_info |
833 | get_registry_info returns correct structure. |
| function | test_has_true |
844 | has returns True for registered interface. |
| function | test_has_false |
850 | has returns False for unregistered interface. |
| function | test_get_all_registrations |
855 | get_all_registrations returns copy of registry. |
| function | test_builder_with_context |
870 | with_context adds key-value to container context. |
| function | test_builder_build_invalid_no_impl_no_factory |
892 | build raises ValueError for registration without impl or factory. |
| function | test_builder_build_invalid_impl_not_subclass |
905 | build raises ValueError when impl doesn't implement interface. |
| function | test_builder_with_component_config_key_match |
923 | with_component uses config when config_key matches. |
| function | test_builder_with_component_interface_name_config |
932 | with_component falls back to interface name lower as config key. |
| function | test_container_registry_has |
950 | |
| function | test_container_registry_shutdown_all |
957 | |
| function | test_resolve_catches_recursion_error |
969 | resolve() catches RecursionError from _resolve_with_context and raises RuntimeError. |
| function | test_request_scope_cache_hit_in_resolve_with_context |
983 | REQUEST scope cache hit inside _resolve_with_context via context.cache. |
| function | test_request_scope_caches_in_context_on_resolve |
994 | REQUEST scope stores resolved instance in context.cache. |
| function | test_create_instance_with_none_implementation_and_factory |
1006 | _create_instance with implementation=None uses factory. |
| function | test_create_instance_raises_for_no_implementation_and_no_factory |
1020 | _create_instance defensively raises when given a registration with |
| function | test_resolve_untyped_param_with_default |
1032 | Untyped param with default uses default when not in context. |
| function | test_resolve_typed_param_no_context_no_default_no_config |
1061 | Typed param not in context, no default, not in config raises ValueError. |
| function | test_resolve_dependencies_with_none_implementation |
1090 | _resolve_dependencies returns empty dict when implementation is None. |