| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,7 @@ common = ["protobuf"] | |||
| 17 | 17 | torch = ["torch"] | |
| 18 | 18 | ||
| 19 | 19 | [tool.poetry.dev-dependencies] | |
| 20 | - pytest = "^5.2" | ||
| 20 | + pytest = "^6.1" | ||
| 21 | 21 | pre-commit = "^2.20.0" | |
| 22 | 22 | jupyterlab = "^3.5.0" | |
| 23 | 23 | mypy = "^0.990" | |
@@ -29,6 +29,8 @@ ruff = "^0.0.117" | |||
| 29 | 29 | [tool.poetry.group.dev.dependencies] | |
| 30 | 30 | fastapi = "^0.87.0" | |
| 31 | 31 | uvicorn = "^0.19.0" | |
| 32 | + httpx = "^0.23.0" | ||
| 33 | + pytest-asyncio = "^0.20.2" | ||
| 32 | 34 | ||
| 33 | 35 | [build-system] | |
| 34 | 36 | requires = ["poetry-core>=1.0.0"] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,30 @@ | |||
| 1 | + import pytest | ||
| 2 | + from fastapi import FastAPI | ||
| 3 | + from httpx import AsyncClient | ||
| 4 | + | ||
| 5 | + from docarray import Document, Image, Text | ||
| 6 | + | ||
| 7 | + | ||
| 8 | + class Mmdoc(Document): | ||
| 9 | + img: Image | ||
| 10 | + text: Text | ||
| 11 | + title: str | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + @pytest.mark.asyncio | ||
| 15 | + async def test_fast_api(): | ||
| 16 | + | ||
| 17 | + app = FastAPI() | ||
| 18 | + | ||
| 19 | + @app.post("/doc/") | ||
| 20 | + async def create_item(doc: Mmdoc): | ||
| 21 | + return doc | ||
| 22 | + | ||
| 23 | + async with AsyncClient(app=app, base_url="http://test") as ac: | ||
| 24 | + # response = await ac.get("/doc") | ||
| 25 | + response2 = await ac.get("/docs") | ||
| 26 | + | ||
| 27 | + # assert response.status_code == 200 | ||
| 28 | + assert response2.status_code == 200 | ||
| 29 | + | ||
| 30 | + # assert response.json() == {"message": "Tomato"} | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments