1import pytest
2
3from testsuite import utils
4
5
6pytest_plugins = ['pytest_userver.plugins.core']
7
8USERVER_CONFIG_HOOKS = ['userver_config_translations']
9
10
11@pytest.fixture(scope='session')
12def userver_config_translations(mockserver_info):
13 def do_patch(config_yaml, config_vars):
14 components = config_yaml['components_manager']['components']
15 components['cache-http-translations']['translations-url'] = (
16 mockserver_info.url('v1/translations')
17 )
18
19 return do_patch
20
21
22
23
24@pytest.fixture(autouse=True)
25def mock_translations(mockserver, translations, mocked_time):
26 @mockserver.json_handler('/v1/translations')
27 def mock(request):
28 return {
29 'content': translations,
30 'update_time': utils.timestring(mocked_time.now()),
31 }
32
33 return mock
34
35
36
37
38@pytest.fixture(name='translations')
39def _translations():
40 return {
41 'hello': {'en': 'hello', 'ru': 'Привет'},
42 'welcome': {'ru': 'Добро пожаловать', 'en': 'Welcome'},
43 }
44