1import pathlib
2
3import pytest
4
5from testsuite.databases.pgsql import discover
6
7pytest_plugins = ['pytest_userver.plugins.postgresql']
8
9
10@pytest.fixture(name='service_source_dir', scope='session')
11def _service_source_dir():
12 """Path to root directory service."""
13 return pathlib.Path(__file__).parent.parent
14
15
16@pytest.fixture(scope='session')
17def initial_data_path(service_source_dir):
18 """Path for find files with data"""
19 return [service_source_dir / 'postgresql/data']
20
21
22@pytest.fixture(scope='session')
23def pgsql_local(service_source_dir, pgsql_local_create):
24 """Create schemas databases for tests"""
25 databases = discover.find_schemas(
26 'auth',
27 [service_source_dir.joinpath('postgresql/schemas')],
28 )
29 return pgsql_local_create(list(databases.values()))
30
31
32@pytest.fixture(scope='session')
33def service_env():
34 return {
35 'SERVER_DIGEST_AUTH_SECRET': ('{ "http_server_digest_auth_secret": "some-private-key" }'),
36 }