Update sanic example with wiring_config

This commit is contained in:
Roman Mogylatov 2021-10-27 20:58:24 -04:00
parent dc6311d2e2
commit 04faec5b00
3 changed files with 5 additions and 4 deletions

View File

@ -104,13 +104,13 @@ The output should be something like:
giphynavigator/tests.py ... [100%] giphynavigator/tests.py ... [100%]
---------- coverage: platform darwin, python 3.9 ----------- ---------- coverage: platform darwin, python 3.10.0-final-0 ----------
Name Stmts Miss Cover Name Stmts Miss Cover
--------------------------------------------------- ---------------------------------------------------
giphynavigator/__init__.py 0 0 100% giphynavigator/__init__.py 0 0 100%
giphynavigator/__main__.py 4 4 0% giphynavigator/__main__.py 4 4 0%
giphynavigator/application.py 11 0 100% giphynavigator/application.py 10 0 100%
giphynavigator/containers.py 6 0 100% giphynavigator/containers.py 7 0 100%
giphynavigator/giphy.py 14 9 36% giphynavigator/giphy.py 14 9 36%
giphynavigator/handlers.py 11 0 100% giphynavigator/handlers.py 11 0 100%
giphynavigator/services.py 9 1 89% giphynavigator/services.py 9 1 89%

View File

@ -10,7 +10,6 @@ def create_app() -> Sanic:
"""Create and return Sanic application.""" """Create and return Sanic application."""
container = Container() container = Container()
container.config.giphy.api_key.from_env("GIPHY_API_KEY") container.config.giphy.api_key.from_env("GIPHY_API_KEY")
container.wire(modules=[handlers])
app = Sanic("giphy-navigator") app = Sanic("giphy-navigator")
app.ctx.container = container app.ctx.container = container

View File

@ -7,6 +7,8 @@ from . import giphy, services
class Container(containers.DeclarativeContainer): class Container(containers.DeclarativeContainer):
wiring_config = containers.WiringConfiguration(modules=[".handlers"])
config = providers.Configuration(yaml_files=["config.yml"]) config = providers.Configuration(yaml_files=["config.yml"])
giphy_client = providers.Factory( giphy_client = providers.Factory(