tests: setup wcs with postgresql storage (#67403)
This commit is contained in:
parent
74eb8aa08c
commit
9b264652a1
|
@ -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')
|
||||
|
||||
|
|
Loading…
Reference in New Issue