Github   Telegram
Loading...
Searching...
No Matches
samples/production_service/tests/conftest.py
1import json
2
3import pytest
4
5from testsuite import utils
6
7pytest_plugins = ['pytest_userver.plugins', 'pytest_userver.plugins.samples']
8
9
10# /// [config hook]
11USERVER_CONFIG_HOOKS = ['userver_config_configs_client']
12
13
14@pytest.fixture(scope='session')
15def userver_config_configs_client(mockserver_info):
16 def do_patch(config_yaml, config_vars):
17 components = config_yaml['components_manager']['components']
18 components['dynamic-config-client'][
19 'config-url'
20 ] = mockserver_info.base_url.rstrip('/')
21
22 return do_patch
23 # /// [config hook]
24
25
26@pytest.fixture(autouse=True)
27def mock_config_server(mockserver, mocked_time):
28 @mockserver.json_handler('/configs/values')
29 def mock_configs_values(request):
30 return {
31 'configs': [],
32 'updated_at': utils.timestring(mocked_time.now()),
33 }
34
35 return mock_configs_values
36
37
38@pytest.fixture
39def config_default_values(service_source_dir):
40 with service_source_dir.joinpath(
41 'dynamic_config_fallback.json',
42 ).open() as fp:
43 return json.load(fp)