python-dependency-injector/examples/providers/configuration/configuration_multiple.py

15 lines
563 B
Python
Raw Normal View History

2020-06-25 21:12:16 +00:00
"""`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'