graphql-engine/server/tests-py/conftest.py

26 lines
766 B
Python
Raw Normal View History

2018-09-18 09:21:57 +03:00
import pytest
import time
2018-09-18 09:21:57 +03:00
from context import HGECtx, HGECtxError
def pytest_addoption(parser):
parser.addoption(
"--hge-url", metavar="HGE_URL", help="url for graphql-engine", required=True
)
parser.addoption(
"--pg-url", metavar="PG_URL", help="url for connecting to Postgres directly", required=True
)
@pytest.fixture(scope='session')
def hge_ctx(request):
print ("create hge_ctx")
hge_url = request.config.getoption('--hge-url')
pg_url = request.config.getoption('--pg-url')
try:
hge_ctx = HGECtx(hge_url=hge_url, pg_url=pg_url)
except HGECtxError as e:
pytest.exit(str(e))
yield hge_ctx # provide the fixture value
print("teardown hge_ctx")
hge_ctx.teardown()
time.sleep(2)