Skip to content

Commit 93dad6b

Browse files
committed
Update quotes in aiohttp example
1 parent 320d837 commit 93dad6b

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed

examples/miniapps/aiohttp/giphynavigator/application.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
def create_app() -> web.Application:
1010
container = Container()
11-
container.config.from_yaml('config.yml')
12-
container.config.giphy.api_key.from_env('GIPHY_API_KEY')
11+
container.config.from_yaml("config.yml")
12+
container.config.giphy.api_key.from_env("GIPHY_API_KEY")
1313
container.wire(modules=[handlers])
1414

1515
app = web.Application()
1616
app.container = container
1717
app.add_routes([
18-
web.get('/', handlers.index),
18+
web.get("/", handlers.index),
1919
])
2020
return app

examples/miniapps/aiohttp/giphynavigator/giphy.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55

66
class GiphyClient:
77

8-
API_URL = 'https://api.giphy.com/v1'
8+
API_URL = "https://api.giphy.com/v1"
99

1010
def __init__(self, api_key, timeout):
1111
self._api_key = api_key
1212
self._timeout = ClientTimeout(timeout)
1313

1414
async def search(self, query, limit):
1515
"""Make search API call and return result."""
16-
url = f'{self.API_URL}/gifs/search'
16+
url = f"{self.API_URL}/gifs/search"
1717
params = {
18-
'q': query,
19-
'api_key': self._api_key,
20-
'limit': limit,
18+
"q": query,
19+
"api_key": self._api_key,
20+
"limit": limit,
2121
}
2222
async with ClientSession(timeout=self._timeout) as session:
2323
async with session.get(url, params=params) as response:

examples/miniapps/aiohttp/giphynavigator/handlers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ async def index(
1414
default_query: str = Provide[Container.config.default.query],
1515
default_limit: int = Provide[Container.config.default.limit.as_int()],
1616
) -> web.Response:
17-
query = request.query.get('query', default_query)
18-
limit = int(request.query.get('limit', default_limit))
17+
query = request.query.get("query", default_query)
18+
limit = int(request.query.get("limit", default_limit))
1919

2020
gifs = await search_service.search(query, limit)
2121

2222
return web.json_response(
2323
{
24-
'query': query,
25-
'limit': limit,
26-
'gifs': gifs,
24+
"query": query,
25+
"limit": limit,
26+
"gifs": gifs,
2727
},
2828
)

examples/miniapps/aiohttp/giphynavigator/services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ async def search(self, query, limit):
1515

1616
result = await self._giphy_client.search(query, limit)
1717

18-
return [{'url': gif['url']} for gif in result['data']]
18+
return [{"url": gif["url"]} for gif in result["data"]]

examples/miniapps/aiohttp/giphynavigator/tests.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,57 +23,57 @@ def client(app, aiohttp_client, loop):
2323
async def test_index(client, app):
2424
giphy_client_mock = mock.AsyncMock(spec=GiphyClient)
2525
giphy_client_mock.search.return_value = {
26-
'data': [
27-
{'url': 'https://giphy.com/gif1.gif'},
28-
{'url': 'https://giphy.com/gif2.gif'},
26+
"data": [
27+
{"url": "https://giphy.com/gif1.gif"},
28+
{"url": "https://giphy.com/gif2.gif"},
2929
],
3030
}
3131

3232
with app.container.giphy_client.override(giphy_client_mock):
3333
response = await client.get(
34-
'/',
34+
"/",
3535
params={
36-
'query': 'test',
37-
'limit': 10,
36+
"query": "test",
37+
"limit": 10,
3838
},
3939
)
4040

4141
assert response.status == 200
4242
data = await response.json()
4343
assert data == {
44-
'query': 'test',
45-
'limit': 10,
46-
'gifs': [
47-
{'url': 'https://giphy.com/gif1.gif'},
48-
{'url': 'https://giphy.com/gif2.gif'},
44+
"query": "test",
45+
"limit": 10,
46+
"gifs": [
47+
{"url": "https://giphy.com/gif1.gif"},
48+
{"url": "https://giphy.com/gif2.gif"},
4949
],
5050
}
5151

5252

5353
async def test_index_no_data(client, app):
5454
giphy_client_mock = mock.AsyncMock(spec=GiphyClient)
5555
giphy_client_mock.search.return_value = {
56-
'data': [],
56+
"data": [],
5757
}
5858

5959
with app.container.giphy_client.override(giphy_client_mock):
60-
response = await client.get('/')
60+
response = await client.get("/")
6161

6262
assert response.status == 200
6363
data = await response.json()
64-
assert data['gifs'] == []
64+
assert data["gifs"] == []
6565

6666

6767
async def test_index_default_params(client, app):
6868
giphy_client_mock = mock.AsyncMock(spec=GiphyClient)
6969
giphy_client_mock.search.return_value = {
70-
'data': [],
70+
"data": [],
7171
}
7272

7373
with app.container.giphy_client.override(giphy_client_mock):
74-
response = await client.get('/')
74+
response = await client.get("/")
7575

7676
assert response.status == 200
7777
data = await response.json()
78-
assert data['query'] == app.container.config.default.query()
79-
assert data['limit'] == app.container.config.default.limit()
78+
assert data["query"] == app.container.config.default.query()
79+
assert data["limit"] == app.container.config.default.limit()

0 commit comments

Comments
 (0)