From 9b264652a179998510dd7ab2eb7501df7f18ecfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 15 Jul 2022 18:52:59 +0200 Subject: [PATCH] tests: setup wcs with postgresql storage (#67403) --- tests/conftest.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 41a10cc..3a64399 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -50,6 +50,15 @@ def postgres_db(): db.delete() +@pytest.fixture +def wcs_db(): + db = Database() + try: + yield db + finally: + db.delete() + + WCS_SCRIPTS = { 'setup-auth': u""" from quixote import get_publisher @@ -57,6 +66,13 @@ from quixote import get_publisher get_publisher().cfg['identification'] = {'methods': ['password']} get_publisher().cfg['debug'] = {'display_exceptions': 'text'} get_publisher().write_cfg() +""", + 'setup-storage': u""" +from quixote import get_publisher + +get_publisher().cfg['postgresql'] = {'database': %(dbname)r, 'port': %(port)r, 'host': %(host)r, 'user': %(user)r, 'password': %(password)r} +get_publisher().write_cfg() +get_publisher().initialize_sql() """, 'create-user': u""" from quixote import get_publisher @@ -171,7 +187,7 @@ def wcs_dir(tmp_path_factory): @pytest.fixture -def wcs(tmp_path_factory, wcs_dir): +def wcs(tmp_path_factory, wcs_dir, wcs_db): '''Session scoped wcs fixture, so read-only.''' PORT = 8899 ADDRESS = '0.0.0.0' @@ -181,6 +197,14 @@ def wcs(tmp_path_factory, wcs_dir): tenant_dir.mkdir() utils.run_wcs_script(wcs_dir, WCS_SCRIPTS['setup-auth'], 'setup-auth') + utils.run_wcs_script(wcs_dir, WCS_SCRIPTS['setup-storage'] % { + 'dbname': wcs_db.db_name, + 'port': os.environ.get('PGPORT'), + 'host': os.environ.get('PGHOST'), + 'user': os.environ.get('PGUSER'), + 'password': os.environ.get('PGPASSWORD'), + }, + 'setup-storage') utils.run_wcs_script(wcs_dir, WCS_SCRIPTS['create-user'], 'create-user') utils.run_wcs_script(wcs_dir, WCS_SCRIPTS['create-data'], 'create-data')