python-dependency-injector/examples/providers/configuration/configuration_multiple.py
2020-06-25 17:12:16 -04:00

15 lines
563 B
Python

"""`Configuration` provider values loading example."""
from dependency_injector import providers
config = providers.Configuration()
config.from_yaml('examples/providers/configuration/config.yml')
config.from_yaml('examples/providers/configuration/config.local.yml')
assert config() == {'aws': {'access_key_id': 'LOCAL-KEY', 'secret_access_key': 'LOCAL-SECRET'}}
assert config.aws() == {'access_key_id': 'LOCAL-KEY', 'secret_access_key': 'LOCAL-SECRET'}
assert config.aws.access_key_id() == 'LOCAL-KEY'
assert config.aws.secret_access_key() == 'LOCAL-SECRET'