test: add first test

This commit is contained in:
arkohut 2024-06-01 13:46:30 +08:00
parent ec03b818f3
commit 5c850a56c1
2 changed files with 16 additions and 0 deletions

View File

@ -33,6 +33,11 @@ def get_db():
db.close()
@app.get("/")
def root():
return {"healthy": True}
@app.post("/libraries", response_model=Library)
def new_library(library_param: NewLibraryParam, db: Session = Depends(get_db)):
library = create_library(library_param, db)

11
memos/test_server.py Normal file
View File

@ -0,0 +1,11 @@
from fastapi.testclient import TestClient
from .server import app
client = TestClient(app)
def test_read_main():
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"healthy": True}