0001-tests-setup-wcs-with-postgresql-storage-67403.patch
tests/conftest.py | ||
---|---|---|
50 | 50 |
db.delete() |
51 | 51 | |
52 | 52 | |
53 |
@pytest.fixture |
|
54 |
def wcs_db(): |
|
55 |
db = Database() |
|
56 |
try: |
|
57 |
yield db |
|
58 |
finally: |
|
59 |
db.delete() |
|
60 | ||
61 | ||
53 | 62 |
WCS_SCRIPTS = { |
54 | 63 |
'setup-auth': u""" |
55 | 64 |
from quixote import get_publisher |
... | ... | |
57 | 66 |
get_publisher().cfg['identification'] = {'methods': ['password']} |
58 | 67 |
get_publisher().cfg['debug'] = {'display_exceptions': 'text'} |
59 | 68 |
get_publisher().write_cfg() |
69 |
""", |
|
70 |
'setup-storage': u""" |
|
71 |
from quixote import get_publisher |
|
72 | ||
73 |
get_publisher().cfg['postgresql'] = {'database': %(dbname)r, 'port': %(port)r, 'host': %(host)r, 'user': %(user)r, 'password': %(password)r} |
|
74 |
get_publisher().write_cfg() |
|
75 |
get_publisher().initialize_sql() |
|
60 | 76 |
""", |
61 | 77 |
'create-user': u""" |
62 | 78 |
from quixote import get_publisher |
... | ... | |
171 | 187 | |
172 | 188 | |
173 | 189 |
@pytest.fixture |
174 |
def wcs(tmp_path_factory, wcs_dir): |
|
190 |
def wcs(tmp_path_factory, wcs_dir, wcs_db):
|
|
175 | 191 |
'''Session scoped wcs fixture, so read-only.''' |
176 | 192 |
PORT = 8899 |
177 | 193 |
ADDRESS = '0.0.0.0' |
... | ... | |
181 | 197 |
tenant_dir.mkdir() |
182 | 198 | |
183 | 199 |
utils.run_wcs_script(wcs_dir, WCS_SCRIPTS['setup-auth'], 'setup-auth') |
200 |
utils.run_wcs_script(wcs_dir, WCS_SCRIPTS['setup-storage'] % { |
|
201 |
'dbname': wcs_db.db_name, |
|
202 |
'port': os.environ.get('PGPORT'), |
|
203 |
'host': os.environ.get('PGHOST'), |
|
204 |
'user': os.environ.get('PGUSER'), |
|
205 |
'password': os.environ.get('PGPASSWORD'), |
|
206 |
}, |
|
207 |
'setup-storage') |
|
184 | 208 |
utils.run_wcs_script(wcs_dir, WCS_SCRIPTS['create-user'], 'create-user') |
185 | 209 |
utils.run_wcs_script(wcs_dir, WCS_SCRIPTS['create-data'], 'create-data') |
186 | 210 | |
187 |
- |