tessl install tessl/pypi-rodi@2.0.0Implementation of dependency injection for Python 3
Agent Success
Agent success rate when using this tile
92%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.06x
Baseline
Agent success rate without this tile
87%
Build a configuration management system that loads and provides access to different types of configuration collections. The system should support multiple configuration sources with strong type safety.
Implement a configuration management system with the following features:
Configuration Data Classes:
DatabaseConfig dataclass with fields: host (str), port (int), name (str)ApiEndpoint dataclass with fields: name (str), url (str), timeout (int)FeatureFlag dataclass with fields: key (str), enabled (bool)Configuration Providers:
ConfigurationService class that:
DatabaseConfig instances)ApiEndpoint configurationsApplication Service:
ApplicationBootstrap class that depends on:
Dependency Injection Setup:
ConfigurationService and ApplicationBootstrap classesApplicationBootstrap receives all configurations correctlyConfigurationService must use type-annotated constructor parametersProvides dependency injection support for managing service lifecycles and dependencies.
File: test_config.py
# Verify that ConfigurationService can be resolved and receives
# the correct number of database configs (3) and endpoint configs (3)
def test_resolve_configuration_service():
container = setup_container()
provider = container.build_provider()
service = provider.get(ConfigurationService)
assert service is not None
assert len(service.database_configs) == 3
assert len(service.endpoint_configs) == 3File: test_config.py
# Verify that the endpoint configurations dictionary has the correct keys
# and contains properly structured ApiEndpoint objects
def test_endpoint_configuration_structure():
container = setup_container()
provider = container.build_provider()
service = provider.get(ConfigurationService)
assert "auth" in service.endpoint_configs
assert "users" in service.endpoint_configs
assert service.endpoint_configs["auth"].url is not NoneFile: test_config.py
# Verify that ApplicationBootstrap receives all injected collections
# and that optional feature flags are properly injected
def test_application_bootstrap():
container = setup_container()
provider = container.build_provider()
bootstrap = provider.get(ApplicationBootstrap)
assert bootstrap is not None
assert bootstrap.databases is not None
assert bootstrap.endpoints is not None
assert bootstrap.feature_flags is not None
assert len(bootstrap.feature_flags) >= 2