Skip to content

Commit 5531e04

Browse files
committed
CHANGES
======= - Fix format errors. Changes to be committed: modified: main.py modified: src/core/config/api.py modified: tests/test_api.py
1 parent 2bd590e commit 5531e04

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

main.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""FastAPI server."""
22

3-
4-
from fastapi import FastAPI, Request
3+
from fastapi import FastAPI, Request, status
54
from fastapi.middleware.cors import CORSMiddleware
65
from fastapi.responses import ORJSONResponse
76

@@ -22,7 +21,12 @@
2221
allow_origins=APIConfig.CORS_ORIGINS,
2322
)
2423

25-
@app.get(f"/{APIConfig.VERSION}/", status_code=200, response_class=ORJSONResponse,)
24+
25+
@app.get(
26+
f"/{APIConfig.VERSION}/",
27+
status_code=status.HTTP_200_OK,
28+
response_class=ORJSONResponse,
29+
)
2630
def home(request: Request) -> ORJSONResponse:
2731
"""Home route."""
28-
return ORJSONResponse(content={"content": "successful response."})
32+
return ORJSONResponse(content={"content": "successful response."})

src/core/config/api.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ class APIConfig:
77
"""API configurations."""
88

99
CORS_ORIGINS: ClassVar[list[str]] = [
10-
"http://127.0.0.1:8000/"
10+
"http://127.0.0.1:8000/",
1111
"https://127.0.0.1:8000/",
12-
"http://127.0.0.1:8000/*"
12+
"http://127.0.0.1:8000/*",
1313
"https://127.0.0.1:8000/*",
1414
"http://locahost:8000/",
15-
"https://localhost:8000/"
15+
"https://localhost:8000/",
1616
]
1717

1818
TITLE: str = "rosa"
19-
DESCRIPTION: str = "Rosa is a simple and fast content management system focussed on modularity and ease of customisation."
20-
VERSION: str = "v1"
19+
DESCRIPTION: str = "Rosa is a simple, modular, customisable and fast CMS."
20+
VERSION: str = "v1"

tests/test_api.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
"""Unit test cases for API endpoints."""
22

3+
from fastapi import status
34
from fastapi.testclient import TestClient
45
from httpx import Response
6+
57
from main import app
68
from src.core.config.api import APIConfig
79

810
client = TestClient(app)
911

12+
1013
def test_home_endpoint() -> None:
14+
"""Test case."""
1115
response: Response = client.get(f"/{APIConfig.VERSION}")
12-
assert response.status_code == 200
16+
assert response.status_code == status.HTTP_200_OK
1317
assert response.headers["content-type"] == "application/json"
1418
assert response.headers["content-length"] == "34"
1519
assert response.encoding == "utf-8"

0 commit comments

Comments
 (0)