Код: Выделить всё
def get_app():
settings = get_settings()
application = FastAPI()
config = {...}
application = create_app(**config)
return application
app = get_app()
@pytest.fixture(scope="module")
def test_app():
client = TestClient(app)
yield client
def test_liveness(test_app):
response = test_app.get("/health/liveness")
assert response.status_code == 200
assert response.json() == {"status": "ready"}
Код: Выделить всё
db_client = class my_class(dataset,project_id,connector_parameters)
await db_client.create_clients()
app.state.db_client = db_client
Код: Выделить всё
if request.app.state.db_client and request.app.state.db_client.is_connected:
return Health(status="ready")
else:
raise HTTPException(status_code=503, detail="Not ready")
< /code>
Ошибка, которую я есть, это: < /p>
AttributeError: 'State' object has no attribute 'db_client'Подробнее здесь: https://stackoverflow.com/questions/793 ... of-fastapi
Мобильная версия