21    Returns a function that adjusts the static configuration file for 
   23    Sets the `dbconnection` to the testsuite started PostgreSQL credentials 
   24    if there's only one `dbconnection` in static config. 
   26    @ingroup userver_testsuite_fixtures 
   31            'Override the "pgsql_local" fixture so that testsuite knowns how ' 
   32            'to start the PostgreSQL database',
 
   35    if len(pgsql_local) > 1:
 
   37            f
'Found more than one entry in "pgsql_local": ' 
   38            f
'{list(pgsql_local.keys())}. ' 
   39            f
'The "userver_pg_config" fixture supports ' 
   40            f
'only one entry in "pgsql_local" fixture. The ' 
   41            f
'"userver_pg_config" fixture should be overridden and ' 
   42            f
'the "dbconnection" for the components::Postgres ' 
   43            f
'components should be adjusted via the overridden fixture.',
 
   46    uri = list(pgsql_local.values())[0].get_uri()
 
   48    def _patch_config(config_yaml, config_vars):
 
   49        components = config_yaml[
'components_manager'][
'components']
 
   52            for name, params 
in components.items()
 
   53            if params 
and 'dbconnection' in params
 
   56        if len(postgre_dbs) > 1:
 
   58                f
'Found more than one components with "dbconnection": ' 
   59                f
'{list(postgre_dbs.keys())}. ' 
   60                f
'The "userver_pg_config" fixture should be overridden and ' 
   61                f
'the "dbconnection" for the components::Postgres ' 
   62                f
'components should be adjusted via the overridden fixture.',
 
   65        for config 
in postgre_dbs.values():
 
   66            config[
'dbconnection'] = uri
 
   67            config.pop(
'dbalias', 
None)