Skip to content

Commit

Permalink
test: Add basic test for litestar example
Browse files Browse the repository at this point in the history
  • Loading branch information
sherbang committed Mar 26, 2024
1 parent c3dba02 commit 10a7216
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Empty file added tests/examples/__init__.py
Empty file.
28 changes: 28 additions & 0 deletions tests/examples/test_litestar.py
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

0 comments on commit 10a7216

Please sign in to comment.