userver: /data/code/userver/libraries/easy/samples/5_pg_service_template/testsuite/conftest.py Source File
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
conftest.py
1import pytest
2
3from testsuite.databases.pgsql import discover
4
5pytest_plugins = ['pytest_userver.plugins.postgresql']
6
7USERVER_CONFIG_HOOKS = ['userver_actions_service']
8
9
10@pytest.fixture(scope='session')
11def initial_data_path(service_source_dir):
12 """Path for find files with data"""
13 return [service_source_dir / 'postgresql/data']
14
15
16@pytest.fixture(scope='session')
17def userver_actions_service(mockserver_info):
18 def do_patch(config_yaml, config_vars):
19 components = config_yaml['components_manager']['components']
20 components['action-client']['service-url'] = mockserver_info.url(
21 '/v1/action',
22 )
23
24 return do_patch
25
26
27@pytest.fixture(scope='session')
28def pgsql_local(service_source_dir, pgsql_local_create):
29 """Create schemas databases for tests"""
30 databases = discover.find_schemas(
31 'pg_service_template', # service name that goes to the DB connection
32 [service_source_dir.joinpath('postgresql/schemas')],
33 )
34 return pgsql_local_create(list(databases.values()))