Server: basic implementation. Not tested => no python installed; bugfix in ESP (uvicorn on port 8090)
This commit is contained in:
1 parent
3694cdf207
commit
8a51e3d95e
38 files changed
+2442
-21
No files matched your search
@@ -0,0 +1,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
# Set before anything imports poorbird.config, whose Settings are cached.
|
||||
os.environ.setdefault("POORBIRD_LOG_LEVEL", "WARNING")
|
||||
os.environ.setdefault("POORBIRD_IMAGE_ROOT", "/tmp/poorbird-test/images")
|
||||
os.environ.setdefault("POORBIRD_THUMB_ROOT", "/tmp/poorbird-test/thumbs")
|
||||
os.environ.setdefault("POORBIRD_STATE_DIR", "/tmp/poorbird-test/state")
|
||||
|
||||
|
||||
def database_is_reachable() -> bool:
|
||||
try:
|
||||
from sqlalchemy import text
|
||||
|
||||
from poorbird.db import engine
|
||||
|
||||
with engine.connect() as conn:
|
||||
conn.execute(text("SELECT 1"))
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
needs_db = pytest.mark.skipif(
|
||||
not database_is_reachable(),
|
||||
reason="no reachable PostgreSQL (set POORBIRD_DATABASE_URL)",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def client():
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from poorbird.api.app import create_app
|
||||
|
||||
with TestClient(create_app()) as c:
|
||||
yield c
|
||||
Reference in new issue
Block a user