コード例 #1
0
def test_ops_healthz_fail(session, client):  # pylint: disable=unused-argument
    """Assert that the service is unhealthy if a connection toThe database cannot be made."""
    engine = sqlalchemy.create_engine('postgresql://*****:*****@exist:5432/nada')
    SESSION.configure(bind=engine)
    rv = client.get('/ops/healthz')

    assert rv.status_code == 500
    assert rv.json() == {'message': 'api is down'}
コード例 #2
0
 def __init__(
     self,
     bind: Union[str, Engine, Connection, None],
     debug: bool = False,
     routes: List[BaseRoute] = None,
     template_directory: str = None,
     title: str = 'Notify API',
     description: str = '',
     version: str = '1.0.0',
     openapi_url: Optional[str] = '/openapi.json',
     openapi_prefix: str = '',
     docs_url: Optional[str] = '/docs',
     redoc_url: Optional[str] = '/redoc',
     **extra: Dict[str, Any],
 ):  # pylint: disable=too-many-arguments
     """Init."""
     super().__init__(debug=debug,
                      routes=routes,
                      template_directory=template_directory,
                      title=title,
                      description=description,
                      version=version,
                      openapi_url=openapi_url,
                      openapi_prefix=openapi_prefix,
                      docs_url=docs_url,
                      redoc_url=redoc_url,
                      **extra)
     if bind is not None:
         if isinstance(bind, str):
             self.bind = create_engine(bind,
                                       pool_pre_ping=True,
                                       pool_size=20)
         else:
             self.bind = bind
         db_session.configure(bind=self.bind)
     else:
         self.bind = None
コード例 #3
0
def engine_fixture():
    """Connect to the database."""
    engine = sqlalchemy.create_engine(AppConfig.SQLALCHEMY_TEST_DATABASE_URI)
    SESSION.configure(bind=engine)
    return engine
コード例 #4
0
def engine_fixture():
    """Connect to the database."""
    engine = sqlalchemy.create_engine(
        get_api_settings().NOTIFY_DATABASE_TEST_URL)
    SESSION.configure(bind=engine)
    return engine