23 Returns a function that adjusts the static configuration file for
25 Sets the `dbconnection` to the testsuite started MongoDB credentials if
26 the `dbconnection` starts with `mongodb://`. Additionally
27 increases MongoDB connection timeouts to 30 seconds.
29 @ingroup userver_testsuite_fixtures
32 port = mongo_connection_info.port
33 host = mongo_connection_info.host
34 new_uri = f
'mongodb://{host}:{port}/'
36 def _patch_config(config_yaml, config_vars):
37 components = config_yaml[
'components_manager'][
'components']
38 for _, params
in components.items():
39 if params
and 'dbconnection' in params:
40 uri = params[
'dbconnection']
41 if not uri.startswith(
'mongodb://'):
44 uri = re.sub(
'mongodb://[^:]+:\\d+/', new_uri, uri)
45 uri = re.sub(
'mongodb://[^:]+/', new_uri, uri)
47 params[
'dbconnection'] = uri
48 params[
'conn_timeout'] =
'30s'
49 params[
'so_timeout'] =
'30s'
50 params.pop(
'dbalias',
None)