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