2021-06-14 05:05:29 +03:00
|
|
|
"""`Configuration` provider values loading example."""
|
|
|
|
|
|
|
|
from datetime import date
|
|
|
|
|
|
|
|
from dependency_injector import containers, providers
|
|
|
|
|
|
|
|
|
|
|
|
class Container(containers.DeclarativeContainer):
|
|
|
|
|
|
|
|
config = providers.Configuration()
|
|
|
|
|
|
|
|
|
2021-09-30 22:32:21 +03:00
|
|
|
if __name__ == "__main__":
|
2021-06-14 05:05:29 +03:00
|
|
|
container = Container()
|
|
|
|
|
2022-04-17 04:39:47 +03:00
|
|
|
container.config.option1.from_value(date(2022, 3, 13))
|
|
|
|
container.config.option2.from_value(date(2022, 3, 14))
|
2021-06-14 05:05:29 +03:00
|
|
|
|
|
|
|
assert container.config() == {
|
2022-04-17 04:39:47 +03:00
|
|
|
"option1": date(2022, 3, 13),
|
|
|
|
"option2": date(2022, 3, 14),
|
2021-06-14 05:05:29 +03:00
|
|
|
}
|
2022-04-17 04:39:47 +03:00
|
|
|
assert container.config.option1() == date(2022, 3, 13)
|
|
|
|
assert container.config.option2() == date(2022, 3, 14)
|