@pytest.fixture
def core_config_mock(request):
    '\n    Fixture to allow having per-test core.config tables without affecting the other parallel tests.\n\n    This override works only in tests which use core function calls directly, not in the ones working\n    via the API, because the normal config table is not touched and the rucio instance answering API\n    calls is not aware of this mock.\n\n    This fixture acts by creating a new copy of the "config" sql table using the :memory: sqlite engine.\n    Accesses to the "models.Config" table are then redirected to this temporary table via mock.patch().\n    '
    from unittest import mock
    from rucio.common.utils import generate_uuid
    from sqlalchemy.pool import StaticPool
    from rucio.db.sqla.models import ModelBase, BASE, Column, String, PrimaryKeyConstraint
    from rucio.db.sqla.session import get_session, get_maker, get_engine, create_engine, declarative_base
    table_content = []
    params = __get_fixture_param(request)
    if params:
        table_content = params.get('table_content', table_content)
    engine = create_engine('sqlite://', connect_args={'check_same_thread': False}, poolclass=StaticPool)
    InMemoryBase = declarative_base(bind=engine)

    class InMemoryConfig(InMemoryBase, ModelBase):
        __tablename__ = ('configs_' + generate_uuid())
        section = Column(String(128))
        opt = Column(String(128))
        value = Column(String(4000))
        _table_args = (PrimaryKeyConstraint('section', 'opt', name='CONFIGS_PK'),)
    InMemoryBase.metadata.create_all()
    current_engine = get_engine()
    get_maker().configure(binds={BASE: current_engine, InMemoryBase: engine})
    session = get_session()()
    for (section, option, value) in (table_content or []):
        InMemoryConfig(section=section, opt=option, value=value).save(flush=True, session=session)
    session.commit()
    with mock.patch('rucio.core.config.models.Config', new=InMemoryConfig):
        (yield)
Fixture to allow having per-test core.config tables without affecting the other parallel tests.

This override works only in tests which use core function calls directly, not in the ones working
via the API, because the normal config table is not touched and the rucio instance answering API
calls is not aware of this mock.

This fixture acts by creating a new copy of the "config" sql table using the :memory: sqlite engine.
Accesses to the "models.Config" table are then redirected to this temporary table via mock.patch().
@pytest.fixture
def core_config_mock(request):
    '\n    Fixture to allow having per-test core.config tables without affecting the other parallel tests.\n\n    This override works only in tests which use core function calls directly, not in the ones working\n    via the API, because the normal config table is not touched and the rucio instance answering API\n    calls is not aware of this mock.\n\n    This fixture acts by creating a new copy of the "config" sql table using the :memory: sqlite engine.\n    Accesses to the "models.Config" table are then redirected to this temporary table via mock.patch().\n    '
    from unittest import mock
    from rucio.common.utils import generate_uuid
    from sqlalchemy.pool import StaticPool
    from rucio.db.sqla.models import ModelBase, BASE, Column, String, PrimaryKeyConstraint
    from rucio.db.sqla.session import get_session, get_maker, get_engine, create_engine, declarative_base
    table_content = []
    params = __get_fixture_param(request)
    if params:
        table_content = params.get('table_content', table_content)
    engine = create_engine('sqlite://', connect_args={'check_same_thread': False}, poolclass=StaticPool)
    InMemoryBase = declarative_base(bind=engine)

    class InMemoryConfig(InMemoryBase, ModelBase):
        __tablename__ = ('configs_' + generate_uuid())
        section = Column(String(128))
        opt = Column(String(128))
        value = Column(String(4000))
        _table_args = (PrimaryKeyConstraint('section', 'opt', name='CONFIGS_PK'),)
    InMemoryBase.metadata.create_all()
    current_engine = get_engine()
    get_maker().configure(binds={BASE: current_engine, InMemoryBase: engine})
    session = get_session()()
    for (section, option, value) in (table_content or []):
        InMemoryConfig(section=section, opt=option, value=value).save(flush=True, session=session)
    session.commit()
    with mock.patch('rucio.core.config.models.Config', new=InMemoryConfig):
        (yield)