-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add basic test for litestar example
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Let's try doing all the things that the frontend is likely to do in the first release. | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
from litestar.testing import TestClient | ||
|
||
from examples.litestar import AuthorCreate, app | ||
|
||
if TYPE_CHECKING: | ||
from litestar import Litestar | ||
|
||
|
||
@pytest.fixture() | ||
def test_client() -> TestClient[Litestar]: | ||
app.debug = True | ||
return TestClient(app=app) | ||
|
||
|
||
async def test_create(test_client: TestClient[Litestar]) -> None: | ||
author = AuthorCreate(name="foo") | ||
|
||
response = test_client.post( | ||
"/authors", | ||
json=author.model_dump(mode="json"), | ||
) | ||
assert response.status_code == 200, response.text |