feat: commit that succeeds

This commit is contained in:
Obi.M 2025-02-21 01:11:20 +01:00
commit 03a6160b09
4 changed files with 36 additions and 0 deletions

11
main.py Normal file
View File

@ -0,0 +1,11 @@
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def read_root():
return {"message": "Hello World"}
@app.get("/items/{item_id}")
async def read_item(item_id: int):
return {"item_id": item_id, "message": "Item details"}

4
pyproject.toml Normal file
View File

@ -0,0 +1,4 @@
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-v"
pythonpath = ["."]

4
requirements.txt Normal file
View File

@ -0,0 +1,4 @@
fastapi>=0.68.0
uvicorn>=0.15.0
pytest>=6.2.4
httpx>=0.19.0

17
tests/test_success.py Normal file
View File

@ -0,0 +1,17 @@
from fastapi.testclient import TestClient
from main import app
client = TestClient(app)
def test_read_root():
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Hello World"}
def test_read_item():
response = client.get("/items/42")
assert response.status_code == 200
assert response.json() == {
"item_id": 42,
"message": "Item details"
}