Update fastapi-sqlalchemy example

This commit is contained in:
Roman Mogylatov 2021-10-27 21:22:17 -04:00
parent 485d6e7179
commit 17be5f9365
4 changed files with 10 additions and 10 deletions

View File

@ -1,4 +1,4 @@
FROM python:3.9-buster FROM python:3.10-buster
ENV PYTHONUNBUFFERED=1 ENV PYTHONUNBUFFERED=1
ENV HOST=0.0.0.0 ENV HOST=0.0.0.0

View File

@ -73,19 +73,19 @@ The output should be something like:
.. code-block:: .. code-block::
platform linux -- Python 3.9.1, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 platform linux -- Python 3.10.0, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /code rootdir: /code
plugins: cov-2.11.1 plugins: cov-3.0.0
collected 7 items collected 7 items
webapp/tests.py ....... [100%] webapp/tests.py ....... [100%]
----------- coverage: platform linux, python 3.9.1-final-0 ----------- ---------- coverage: platform linux, python 3.10.0-final-0 ----------
Name Stmts Miss Cover Name Stmts Miss Cover
-------------------------------------------- --------------------------------------------
webapp/__init__.py 0 0 100% webapp/__init__.py 0 0 100%
webapp/application.py 14 0 100% webapp/application.py 12 0 100%
webapp/containers.py 9 0 100% webapp/containers.py 10 0 100%
webapp/database.py 24 8 67% webapp/database.py 24 8 67%
webapp/endpoints.py 32 0 100% webapp/endpoints.py 32 0 100%
webapp/models.py 10 1 90% webapp/models.py 10 1 90%
@ -93,4 +93,4 @@ The output should be something like:
webapp/services.py 16 0 100% webapp/services.py 16 0 100%
webapp/tests.py 59 0 100% webapp/tests.py 59 0 100%
-------------------------------------------- --------------------------------------------
TOTAL 200 29 86% TOTAL 199 29 85%

View File

@ -8,8 +8,6 @@ from . import endpoints
def create_app() -> FastAPI: def create_app() -> FastAPI:
container = Container() container = Container()
container.config.from_yaml("config.yml")
container.wire(modules=[endpoints])
db = container.db() db = container.db()
db.create_database() db.create_database()

View File

@ -9,7 +9,9 @@ from .services import UserService
class Container(containers.DeclarativeContainer): class Container(containers.DeclarativeContainer):
config = providers.Configuration() wiring_config = containers.WiringConfiguration(modules=[".endpoints"])
config = providers.Configuration(yaml_files=["config.yml"])
db = providers.Singleton(Database, db_url=config.db.url) db = providers.Singleton(Database, db_url=config.db.url)