Feat(API): PostgreSQL database setup
- Fix enviroment variables - Fix the ping route for API - Added database connection for future testing
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
from quart import Response
|
||||
from backend.run import app
|
||||
from quart import Quart
|
||||
|
||||
|
||||
async def test_control() -> None:
|
||||
async def test_control(app: Quart) -> None:
|
||||
test_client = app.test_client()
|
||||
response: Response = await test_client.get("/control/ping")
|
||||
response = await test_client.get("/control/ping/")
|
||||
assert (await response.get_json())["ping"] == "pong"
|
||||
|
20
backend/tests/conftest.py
Normal file
20
backend/tests/conftest.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from typing import AsyncGenerator
|
||||
|
||||
import pytest
|
||||
from quart import Quart
|
||||
from quart_db import Connection
|
||||
|
||||
from backend.run import app, quart_db
|
||||
|
||||
|
||||
@pytest.fixture(name="app", scope="function")
|
||||
async def _app() -> AsyncGenerator[Quart, None]:
|
||||
async with app.test_app():
|
||||
yield app
|
||||
|
||||
|
||||
@pytest.fixture(name="connection", scope="function")
|
||||
async def _connection(app: Quart) -> AsyncGenerator[Connection, None]:
|
||||
async with quart_db.connection() as connection:
|
||||
async with connection.transaction():
|
||||
yield connection
|
Reference in New Issue
Block a user