feat: Quart app factory with health endpoint
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from pathlib import Path
|
||||
import textwrap
|
||||
from fablednetmon.app import create_app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def config_file(tmp_path):
|
||||
f = tmp_path / "config.yaml"
|
||||
f.write_text(textwrap.dedent("""\
|
||||
secret_key: test-secret-key-32-chars-minimum!!
|
||||
database:
|
||||
url: postgresql+asyncpg://test:test@localhost/test
|
||||
"""))
|
||||
return f
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def app(config_file):
|
||||
application = create_app(config_path=config_file, testing=True)
|
||||
return application
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def client(app):
|
||||
return app.test_client()
|
||||
@@ -0,0 +1,21 @@
|
||||
import pytest
|
||||
from fablednetmon.app import create_app
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_app_returns_quart_app(config_file):
|
||||
from quart import Quart
|
||||
app = create_app(config_path=config_file, testing=True)
|
||||
assert isinstance(app, Quart)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_app_has_db_sessionmaker(config_file):
|
||||
app = create_app(config_path=config_file, testing=True)
|
||||
assert hasattr(app, "db_sessionmaker")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_health_endpoint(client):
|
||||
response = await client.get("/health")
|
||||
assert response.status_code == 200
|
||||
Reference in New Issue
Block a user