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