userver: /data/code/userver/libraries/easy/samples/5_pg_service_template/testsuite/conftest.py Source File
Loading...
Searching...
No Matches
conftest.py
1import pathlib
2
3import pytest
4
5from testsuite.databases.pgsql import discover
6
7pytest_plugins = ['pytest_userver.plugins.postgresql']
8
9USERVER_CONFIG_HOOKS = ['userver_actions_service']
10
11
12@pytest.fixture(scope='session')
13def service_source_dir():
14 """Path to root directory service."""
15 return pathlib.Path(__file__).parent.parent
16
17
18@pytest.fixture(scope='session')
19def initial_data_path(service_source_dir):
20 """Path for find files with data"""
21 return [service_source_dir / 'postgresql/data']
22
23
24@pytest.fixture(scope='session')
25def userver_actions_service(mockserver_info):
26 def do_patch(config_yaml, config_vars):
27 components = config_yaml['components_manager']['components']
28 components['action-client']['service-url'] = mockserver_info.url(
29 '/v1/action',
30 )
31
32 return do_patch
33
34
35@pytest.fixture(scope='session')
36def pgsql_local(service_source_dir, pgsql_local_create):
37 """Create schemas databases for tests"""
38 databases = discover.find_schemas(
39 'pg_service_template', # service name that goes to the DB connection
40 [service_source_dir.joinpath('postgresql/schemas')],
41 )
42 return pgsql_local_create(list(databases.values()))