Test and implementation of sonde post
This commit is contained in:
parent
4c64cc8529
commit
ab5d69e44d
12
papi/main.py
12
papi/main.py
|
@ -1,10 +1,16 @@
|
|||
from typing import Optional
|
||||
from pydantic import BaseModel
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class Sonde(BaseModel):
|
||||
identifiant: str
|
||||
nom: str
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def read_root():
|
||||
return {"msg": "Hello World"}
|
||||
|
@ -13,3 +19,9 @@ def read_root():
|
|||
@app.get("/items/{item_id}")
|
||||
def read_item(item_id: int, q: Optional[str] = None):
|
||||
return {"item_id": item_id, "q": q}
|
||||
|
||||
|
||||
@app.post("/sonde/")
|
||||
def post_sonde(sonde: Sonde):
|
||||
print(sonde)
|
||||
return
|
||||
|
|
|
@ -16,3 +16,9 @@ def test_read_main():
|
|||
response = client.get("/")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"msg": "Hello World"}
|
||||
|
||||
|
||||
def test_creer_sonde():
|
||||
sonde1 = {"identifiant": "masonde_001", "nom": "client1"}
|
||||
response = client.post("/sonde/", json=sonde1)
|
||||
assert response.status_code == 200
|
||||
|
|
Loading…
Reference in New Issue