feat: commit that succeeds
This commit is contained in:
commit
03a6160b09
11
main.py
Normal file
11
main.py
Normal 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
4
pyproject.toml
Normal file
@ -0,0 +1,4 @@
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["tests"]
|
||||
addopts = "-v"
|
||||
pythonpath = ["."]
|
4
requirements.txt
Normal file
4
requirements.txt
Normal 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
17
tests/test_success.py
Normal 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"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user