Skip to content

Commit e670377

Browse files
committed
Update quotes in fastapi example
1 parent a917349 commit e670377

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

examples/miniapps/fastapi/giphynavigator/application.py

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

99
def create_app() -> FastAPI:
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=[endpoints])
1414

1515
app = FastAPI()

examples/miniapps/fastapi/giphynavigator/endpoints.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Response(BaseModel):
2323
router = APIRouter()
2424

2525

26-
@router.get('/', response_model=Response)
26+
@router.get("/", response_model=Response)
2727
@inject
2828
async def index(
2929
query: Optional[str] = None,
@@ -38,7 +38,7 @@ async def index(
3838
gifs = await search_service.search(query, limit)
3939

4040
return {
41-
'query': query,
42-
'limit': limit,
43-
'gifs': gifs,
41+
"query": query,
42+
"limit": limit,
43+
"gifs": gifs,
4444
}

examples/miniapps/fastapi/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/fastapi/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/fastapi/giphynavigator/tests.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@pytest.fixture
1313
def client(event_loop):
14-
client = AsyncClient(app=app, base_url='http://test')
14+
client = AsyncClient(app=app, base_url="http://test")
1515
yield client
1616
event_loop.run_until_complete(client.aclose())
1717

@@ -20,29 +20,29 @@ def client(event_loop):
2020
async def test_index(client):
2121
giphy_client_mock = mock.AsyncMock(spec=GiphyClient)
2222
giphy_client_mock.search.return_value = {
23-
'data': [
24-
{'url': 'https://giphy.com/gif1.gif'},
25-
{'url': 'https://giphy.com/gif2.gif'},
23+
"data": [
24+
{"url": "https://giphy.com/gif1.gif"},
25+
{"url": "https://giphy.com/gif2.gif"},
2626
],
2727
}
2828

2929
with app.container.giphy_client.override(giphy_client_mock):
3030
response = await client.get(
31-
'/',
31+
"/",
3232
params={
33-
'query': 'test',
34-
'limit': 10,
33+
"query": "test",
34+
"limit": 10,
3535
},
3636
)
3737

3838
assert response.status_code == 200
3939
data = response.json()
4040
assert data == {
41-
'query': 'test',
42-
'limit': 10,
43-
'gifs': [
44-
{'url': 'https://giphy.com/gif1.gif'},
45-
{'url': 'https://giphy.com/gif2.gif'},
41+
"query": "test",
42+
"limit": 10,
43+
"gifs": [
44+
{"url": "https://giphy.com/gif1.gif"},
45+
{"url": "https://giphy.com/gif2.gif"},
4646
],
4747
}
4848

@@ -51,28 +51,28 @@ async def test_index(client):
5151
async def test_index_no_data(client):
5252
giphy_client_mock = mock.AsyncMock(spec=GiphyClient)
5353
giphy_client_mock.search.return_value = {
54-
'data': [],
54+
"data": [],
5555
}
5656

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

6060
assert response.status_code == 200
6161
data = response.json()
62-
assert data['gifs'] == []
62+
assert data["gifs"] == []
6363

6464

6565
@pytest.mark.asyncio
6666
async def test_index_default_params(client):
6767
giphy_client_mock = mock.AsyncMock(spec=GiphyClient)
6868
giphy_client_mock.search.return_value = {
69-
'data': [],
69+
"data": [],
7070
}
7171

7272
with app.container.giphy_client.override(giphy_client_mock):
73-
response = await client.get('/')
73+
response = await client.get("/")
7474

7575
assert response.status_code == 200
7676
data = response.json()
77-
assert data['query'] == app.container.config.default.query()
78-
assert data['limit'] == app.container.config.default.limit()
77+
assert data["query"] == app.container.config.default.query()
78+
assert data["limit"] == app.container.config.default.limit()

0 commit comments

Comments
 (0)