Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ZipFile committed Dec 8, 2024
1 parent be7abb3 commit f5d2856
Show file tree
Hide file tree
Showing 24 changed files with 70 additions and 62 deletions.
5 changes: 3 additions & 2 deletions examples/miniapps/aiohttp/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ The output should be something like:

.. code-block::
platform darwin -- Python 3.10.0, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
plugins: asyncio-0.16.0, anyio-3.3.4, aiohttp-0.3.0, cov-3.0.0
platform linux -- Python 3.12.3, pytest-8.3.2, pluggy-1.5.0
plugins: cov-6.0.0, anyio-4.4.0, asyncio-0.24.0, aiohttp-1.0.5
asyncio: mode=Mode.STRICT, default_loop_scope=None
collected 3 items
giphynavigator/tests.py ... [100%]
Expand Down
10 changes: 7 additions & 3 deletions examples/miniapps/aiohttp/giphynavigator/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@
from unittest import mock

import pytest
import pytest_asyncio

from giphynavigator.application import create_app
from giphynavigator.giphy import GiphyClient


pytestmark = pytest.mark.asyncio


@pytest.fixture
def app():
app = create_app()
yield app
app.container.unwire()


@pytest.fixture
def client(app, aiohttp_client, loop):
return loop.run_until_complete(aiohttp_client(app))
@pytest_asyncio.fixture
async def client(app, aiohttp_client):
return await aiohttp_client(app)


async def test_index(client, app):
Expand Down
1 change: 1 addition & 0 deletions examples/miniapps/aiohttp/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ dependency-injector
aiohttp
pyyaml
pytest-aiohttp
pytest-asyncio
pytest-cov
2 changes: 1 addition & 1 deletion examples/miniapps/asyncio-daemon/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-buster
FROM python:3.13-bookworm

ENV PYTHONUNBUFFERED=1

Expand Down
6 changes: 3 additions & 3 deletions examples/miniapps/asyncio-daemon/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Build the Docker image:

.. code-block:: bash
docker-compose build
docker compose build
Run the docker-compose environment:

.. code-block:: bash
docker-compose up
docker compose up
The output should be something like:

Expand Down Expand Up @@ -59,7 +59,7 @@ To run the tests do:

.. code-block:: bash
docker-compose run --rm monitor py.test monitoringdaemon/tests.py --cov=monitoringdaemon
docker compose run --rm monitor py.test monitoringdaemon/tests.py --cov=monitoringdaemon
The output should be something like:

Expand Down
2 changes: 1 addition & 1 deletion examples/miniapps/fastapi-redis/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-buster
FROM python:3.13-bookworm

ENV PYTHONUNBUFFERED=1

Expand Down
14 changes: 7 additions & 7 deletions examples/miniapps/fastapi-redis/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Build the Docker image:

.. code-block:: bash
docker-compose build
docker compose build
Run the docker-compose environment:

.. code-block:: bash
docker-compose up
docker compose up
The output should be something like:

Expand Down Expand Up @@ -54,16 +54,16 @@ To run the tests do:

.. code-block:: bash
docker-compose run --rm example py.test fastapiredis/tests.py --cov=fastapiredis
docker compose run --rm example py.test fastapiredis/tests.py --cov=fastapiredis
The output should be something like:

.. code-block::
platform linux -- Python 3.10.9, pytest-7.2.0, pluggy-1.0.0
platform linux -- Python 3.13.1, pytest-8.3.4, pluggy-1.5.0
rootdir: /code
plugins: cov-4.0.0, asyncio-0.20.3
collected 1 item
plugins: cov-6.0.0, asyncio-0.24.0, anyio-4.7.0
asyncio: mode=Mode.STRICT, default_loop_scope=None
fastapiredis/tests.py . [100%]
Expand All @@ -77,4 +77,4 @@ The output should be something like:
fastapiredis/services.py 7 3 57%
fastapiredis/tests.py 18 0 100%
-------------------------------------------------
TOTAL 52 7 87%
TOTAL 52 7 87%
2 changes: 1 addition & 1 deletion examples/miniapps/fastapi-redis/fastapiredis/redis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import AsyncIterator

from aioredis import from_url, Redis
from redis.asyncio import from_url, Redis


async def init_redis_pool(host: str, password: str) -> AsyncIterator[Redis]:
Expand Down
2 changes: 1 addition & 1 deletion examples/miniapps/fastapi-redis/fastapiredis/services.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Services module."""

from aioredis import Redis
from redis.asyncio import Redis


class Service:
Expand Down
2 changes: 1 addition & 1 deletion examples/miniapps/fastapi-redis/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dependency-injector
fastapi
uvicorn
aioredis
redis>=4.2

# For testing:
pytest
Expand Down
5 changes: 3 additions & 2 deletions examples/miniapps/fastapi-simple/tests.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from unittest import mock

import pytest
import pytest_asyncio
from httpx import ASGITransport, AsyncClient

from fastapi_di_example import app, container, Service


@pytest.fixture
async def client(event_loop):
@pytest_asyncio.fixture
async def client():
async with AsyncClient(
transport=ASGITransport(app=app),
base_url="http://test",
Expand Down
2 changes: 1 addition & 1 deletion examples/miniapps/fastapi-sqlalchemy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-buster
FROM python:3.13-bookworm

ENV PYTHONUNBUFFERED=1
ENV HOST=0.0.0.0
Expand Down
10 changes: 5 additions & 5 deletions examples/miniapps/fastapi-sqlalchemy/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Build the Docker image:

.. code-block:: bash
docker-compose build
docker compose build
Run the docker-compose environment:

.. code-block:: bash
docker-compose up
docker compose up
The output should be something like:

Expand Down Expand Up @@ -67,15 +67,15 @@ To run the tests do:

.. code-block:: bash
docker-compose run --rm webapp py.test webapp/tests.py --cov=webapp
docker compose run --rm webapp py.test webapp/tests.py --cov=webapp
The output should be something like:

.. code-block::
platform linux -- Python 3.10.0, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
platform linux -- Python 3.13.1, pytest-8.3.4, pluggy-1.5.0
rootdir: /code
plugins: cov-3.0.0
plugins: cov-6.0.0, anyio-4.7.0
collected 7 items
webapp/tests.py ....... [100%]
Expand Down
2 changes: 1 addition & 1 deletion examples/miniapps/fastapi-sqlalchemy/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dependency-injector
fastapi
fastapi[standard]
uvicorn
pyyaml
sqlalchemy
Expand Down
6 changes: 3 additions & 3 deletions examples/miniapps/fastapi/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ The output should be something like:

.. code-block::
platform darwin -- Python 3.10.0, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
plugins: asyncio-0.16.0, cov-3.0.0
collected 3 items
platform linux -- Python 3.12.3, pytest-8.3.2, pluggy-1.5.0
plugins: cov-6.0.0, anyio-4.4.0, asyncio-0.24.0, aiohttp-1.0.5
asyncio: mode=Mode.STRICT, default_loop_scope=None
giphynavigator/tests.py ... [100%]
Expand Down
3 changes: 2 additions & 1 deletion examples/miniapps/fastapi/giphynavigator/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
from unittest import mock

import pytest
import pytest_asyncio
from httpx import ASGITransport, AsyncClient

from giphynavigator.application import app
from giphynavigator.giphy import GiphyClient


@pytest.fixture
@pytest_asyncio.fixture
async def client():
async with AsyncClient(
transport=ASGITransport(app=app),
Expand Down
5 changes: 3 additions & 2 deletions examples/miniapps/flask-blueprints/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ The output should be something like:

.. code-block::
platform darwin -- Python 3.10.0, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
plugins: cov-3.0.0, flask-1.2.0
platform linux -- Python 3.12.3, pytest-8.3.2, pluggy-1.5.0
plugins: cov-6.0.0, flask-1.3.0
asyncio: mode=Mode.STRICT, default_loop_scope=None
collected 2 items
githubnavigator/tests.py .. [100%]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Application module."""

from flask import Flask
from flask_bootstrap import Bootstrap
from flask_bootstrap import Bootstrap4

from .containers import Container
from .blueprints import example
Expand All @@ -15,7 +15,7 @@ def create_app() -> Flask:
app.container = container
app.register_blueprint(example.blueprint)

bootstrap = Bootstrap()
bootstrap = Bootstrap4()
bootstrap.init_app(app)

return app
5 changes: 3 additions & 2 deletions examples/miniapps/flask/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ The output should be something like:

.. code-block::
platform darwin -- Python 3.10.0, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
plugins: cov-3.0.0, flask-1.2.0
platform linux -- Python 3.12.3, pytest-8.3.2, pluggy-1.5.0
plugins: cov-6.0.0, flask-1.3.0
asyncio: mode=Mode.STRICT, default_loop_scope=None
collected 2 items
githubnavigator/tests.py .. [100%]
Expand Down
4 changes: 2 additions & 2 deletions examples/miniapps/flask/githubnavigator/application.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Application module."""

from flask import Flask
from flask_bootstrap import Bootstrap
from flask_bootstrap import Bootstrap4

from .containers import Container
from . import views
Expand All @@ -15,7 +15,7 @@ def create_app() -> Flask:
app.container = container
app.add_url_rule("/", "index", views.index)

bootstrap = Bootstrap()
bootstrap = Bootstrap4()
bootstrap.init_app(app)

return app
4 changes: 2 additions & 2 deletions examples/miniapps/movie-lister/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ The output should be something like:

.. code-block::
platform darwin -- Python 3.10.0, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
plugins: cov-3.0.0
platform linux -- Python 3.12.3, pytest-8.3.2, pluggy-1.5.0
plugins: cov-6.0.0
collected 2 items
movies/tests.py .. [100%]
Expand Down
7 changes: 4 additions & 3 deletions examples/miniapps/sanic/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ To run the application do:
.. code-block:: bash
export GIPHY_API_KEY=wBJ2wZG7SRqfrU9nPgPiWvORmloDyuL0
python -m giphynavigator
sanic giphynavigator.application:create_app
The output should be something like:

Expand Down Expand Up @@ -98,8 +98,9 @@ The output should be something like:

.. code-block::
platform darwin -- Python 3.10.0, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
plugins: sanic-1.9.1, anyio-3.3.4, cov-3.0.0
platform linux -- Python 3.12.3, pytest-8.3.2, pluggy-1.5.0
plugins: cov-6.0.0, anyio-4.4.0, asyncio-0.24.0
asyncio: mode=Mode.STRICT, default_loop_scope=None
collected 3 items
giphynavigator/tests.py ... [100%]
Expand Down
Loading

0 comments on commit f5d2856

Please sign in to comment.