diff --git a/examples/miniapps/aiohttp/giphynavigator/application.py b/examples/miniapps/aiohttp/giphynavigator/application.py index 848435fb..36b18c93 100644 --- a/examples/miniapps/aiohttp/giphynavigator/application.py +++ b/examples/miniapps/aiohttp/giphynavigator/application.py @@ -8,13 +8,13 @@ from . import handlers def create_app() -> web.Application: container = Container() - container.config.from_yaml('config.yml') - container.config.giphy.api_key.from_env('GIPHY_API_KEY') + container.config.from_yaml("config.yml") + container.config.giphy.api_key.from_env("GIPHY_API_KEY") container.wire(modules=[handlers]) app = web.Application() app.container = container app.add_routes([ - web.get('/', handlers.index), + web.get("/", handlers.index), ]) return app diff --git a/examples/miniapps/aiohttp/giphynavigator/giphy.py b/examples/miniapps/aiohttp/giphynavigator/giphy.py index 22a5f6a4..bab017c5 100644 --- a/examples/miniapps/aiohttp/giphynavigator/giphy.py +++ b/examples/miniapps/aiohttp/giphynavigator/giphy.py @@ -5,7 +5,7 @@ from aiohttp import ClientSession, ClientTimeout class GiphyClient: - API_URL = 'https://api.giphy.com/v1' + API_URL = "https://api.giphy.com/v1" def __init__(self, api_key, timeout): self._api_key = api_key @@ -13,11 +13,11 @@ class GiphyClient: async def search(self, query, limit): """Make search API call and return result.""" - url = f'{self.API_URL}/gifs/search' + url = f"{self.API_URL}/gifs/search" params = { - 'q': query, - 'api_key': self._api_key, - 'limit': limit, + "q": query, + "api_key": self._api_key, + "limit": limit, } async with ClientSession(timeout=self._timeout) as session: async with session.get(url, params=params) as response: diff --git a/examples/miniapps/aiohttp/giphynavigator/handlers.py b/examples/miniapps/aiohttp/giphynavigator/handlers.py index 5a829e82..b4853b32 100644 --- a/examples/miniapps/aiohttp/giphynavigator/handlers.py +++ b/examples/miniapps/aiohttp/giphynavigator/handlers.py @@ -14,15 +14,15 @@ async def index( default_query: str = Provide[Container.config.default.query], default_limit: int = Provide[Container.config.default.limit.as_int()], ) -> web.Response: - query = request.query.get('query', default_query) - limit = int(request.query.get('limit', default_limit)) + query = request.query.get("query", default_query) + limit = int(request.query.get("limit", default_limit)) gifs = await search_service.search(query, limit) return web.json_response( { - 'query': query, - 'limit': limit, - 'gifs': gifs, + "query": query, + "limit": limit, + "gifs": gifs, }, ) diff --git a/examples/miniapps/aiohttp/giphynavigator/services.py b/examples/miniapps/aiohttp/giphynavigator/services.py index 1c86e0d7..1ee6eb64 100644 --- a/examples/miniapps/aiohttp/giphynavigator/services.py +++ b/examples/miniapps/aiohttp/giphynavigator/services.py @@ -15,4 +15,4 @@ class SearchService: result = await self._giphy_client.search(query, limit) - return [{'url': gif['url']} for gif in result['data']] + return [{"url": gif["url"]} for gif in result["data"]] diff --git a/examples/miniapps/aiohttp/giphynavigator/tests.py b/examples/miniapps/aiohttp/giphynavigator/tests.py index 7f9046e6..84eddc60 100644 --- a/examples/miniapps/aiohttp/giphynavigator/tests.py +++ b/examples/miniapps/aiohttp/giphynavigator/tests.py @@ -23,29 +23,29 @@ def client(app, aiohttp_client, loop): async def test_index(client, app): giphy_client_mock = mock.AsyncMock(spec=GiphyClient) giphy_client_mock.search.return_value = { - 'data': [ - {'url': 'https://giphy.com/gif1.gif'}, - {'url': 'https://giphy.com/gif2.gif'}, + "data": [ + {"url": "https://giphy.com/gif1.gif"}, + {"url": "https://giphy.com/gif2.gif"}, ], } with app.container.giphy_client.override(giphy_client_mock): response = await client.get( - '/', + "/", params={ - 'query': 'test', - 'limit': 10, + "query": "test", + "limit": 10, }, ) assert response.status == 200 data = await response.json() assert data == { - 'query': 'test', - 'limit': 10, - 'gifs': [ - {'url': 'https://giphy.com/gif1.gif'}, - {'url': 'https://giphy.com/gif2.gif'}, + "query": "test", + "limit": 10, + "gifs": [ + {"url": "https://giphy.com/gif1.gif"}, + {"url": "https://giphy.com/gif2.gif"}, ], } @@ -53,27 +53,27 @@ async def test_index(client, app): async def test_index_no_data(client, app): giphy_client_mock = mock.AsyncMock(spec=GiphyClient) giphy_client_mock.search.return_value = { - 'data': [], + "data": [], } with app.container.giphy_client.override(giphy_client_mock): - response = await client.get('/') + response = await client.get("/") assert response.status == 200 data = await response.json() - assert data['gifs'] == [] + assert data["gifs"] == [] async def test_index_default_params(client, app): giphy_client_mock = mock.AsyncMock(spec=GiphyClient) giphy_client_mock.search.return_value = { - 'data': [], + "data": [], } with app.container.giphy_client.override(giphy_client_mock): - response = await client.get('/') + response = await client.get("/") assert response.status == 200 data = await response.json() - assert data['query'] == app.container.config.default.query() - assert data['limit'] == app.container.config.default.limit() + assert data["query"] == app.container.config.default.query() + assert data["limit"] == app.container.config.default.limit()