Skip to content

Commit

Permalink
add test for application class
Browse files Browse the repository at this point in the history
  • Loading branch information
livioribeiro committed Dec 8, 2023
1 parent 6a85f22 commit e6198ea
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ packages = [
[tool.poetry.dependencies]
python = "^3.11"
asgikit = "^0.5"
pydantic = "^2.4"
pydantic = "^2.5"
loguru = "^0.7"
python-dotenv = "^1.0.0"
jinja2 = { version = "^3.1", optional = true }
Expand All @@ -52,6 +52,7 @@ pytest = "^7.4"
pytest-asyncio = "^0.21"
pytest-cov = "^4.1"
coverage = { version = "^7.3", extras = ["toml"] }
httpx = "^0.25"

[tool.poetry.group.lint]
optional = true
Expand Down
Empty file.
9 changes: 9 additions & 0 deletions tests/web/application/application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from asgikit.responses import respond_text
from selva.web import controller, get


@controller
class Controller:
@get
async def index(self, request):
await respond_text(request.response, "Selva")
19 changes: 19 additions & 0 deletions tests/web/application/test_application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sys
from pathlib import Path

from httpx import AsyncClient

from selva.configuration.defaults import default_settings
from selva.configuration.settings import Settings
from selva.web.application import Selva


async def test_application():
settings = Settings(default_settings | {
"components": ["tests.web.application.application"]
})
app = Selva(settings)

client = AsyncClient(app=app)
response = await client.get("http://localhost:8000/")
assert response.text == "Selva"

0 comments on commit e6198ea

Please sign in to comment.