Update movie lister example

This commit is contained in:
Roman Mogylatov 2021-10-27 19:45:49 -04:00
parent da636171de
commit ff91f0bda2
4 changed files with 19 additions and 19 deletions

View File

@ -58,21 +58,21 @@ The output should be something like:
.. code-block:: .. code-block::
platform darwin -- Python 3.9, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 platform darwin -- Python 3.10.0, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
plugins: cov-2.10.0 plugins: cov-3.0.0
collected 2 items collected 2 items
movies/tests.py .. [100%] movies/tests.py .. [100%]
---------- coverage: platform darwin, python 3.9 ----------- ---------- coverage: platform darwin, python 3.10 -----------
Name Stmts Miss Cover Name Stmts Miss Cover
------------------------------------------ ------------------------------------------
movies/__init__.py 0 0 100% movies/__init__.py 0 0 100%
movies/__main__.py 18 18 0% movies/__main__.py 16 16 0%
movies/containers.py 9 0 100% movies/containers.py 9 0 100%
movies/entities.py 7 1 86% movies/entities.py 7 1 86%
movies/finders.py 26 13 50% movies/finders.py 26 13 50%
movies/listers.py 8 0 100% movies/listers.py 8 0 100%
movies/tests.py 24 0 100% movies/tests.py 23 0 100%
------------------------------------------ ------------------------------------------
TOTAL 92 32 65% TOTAL 89 30 66%

View File

@ -19,7 +19,6 @@ def main(lister: MovieLister = Provide[Container.lister]) -> None:
if __name__ == "__main__": if __name__ == "__main__":
container = Container() container = Container()
container.config.from_yaml("config.yml")
container.config.finder.type.from_env("MOVIE_FINDER_TYPE") container.config.finder.type.from_env("MOVIE_FINDER_TYPE")
container.wire(modules=[__name__]) container.wire(modules=[__name__])

View File

@ -7,7 +7,7 @@ from . import finders, listers, entities
class Container(containers.DeclarativeContainer): class Container(containers.DeclarativeContainer):
config = providers.Configuration() config = providers.Configuration(yaml_files=["config.yml"])
movie = providers.Factory(entities.Movie) movie = providers.Factory(entities.Movie)

View File

@ -9,19 +9,20 @@ from .containers import Container
@pytest.fixture @pytest.fixture
def container(): def container():
container = Container() container = Container(
container.config.from_dict({ config={
"finder": { "finder": {
"type": "csv", "type": "csv",
"csv": { "csv": {
"path": "/fake-movies.csv", "path": "/fake-movies.csv",
"delimiter": ",", "delimiter": ",",
}, },
"sqlite": { "sqlite": {
"path": "/fake-movies.db", "path": "/fake-movies.db",
},
}, },
}, },
}) )
return container return container