"""Arquivo para fixtures"""
from unittest.mock import patch
from pytest import fixture
from sqlmodel import create_engine, SQLModel
from tests.mocks import mock_user
from mitmirror.infra.entities import *  # pylint: disable=W0614, W0401


user = mock_user()


@fixture(scope="module")
def fake_user():
    """Mock de usuario"""

    return user


@fixture(autouse=True, scope="function")
def separate_database(request):
    """
    Cria um mock do banco de dados para que cada teste use um banco separado.
    """

    tmpdir = request.getfixturevalue("tmpdir")
    test_db = tmpdir.join("mitmirror.test.db")
    engine = create_engine(f"sqlite:///{test_db}")
    SQLModel.metadata.create_all(engine)
    with patch("mitmirror.infra.config.database_config.engine", engine):
        yield

sqlmodel.SQLModel.metadata.create_all sqlmodel.create_engine tests.mocks.mock_user pytest.fixture unittest.mock.patch
[((246, 257), 'tests.mocks.mock_user', 'mock_user', ([], {}), '()\n', (255, 257), False, 'from tests.mocks import mock_user\n'), ((261, 284), 'pytest.fixture', 'fixture', ([], {'scope': '"""module"""'}), "(scope='module')\n", (268, 284), False, 'from pytest import fixture\n'), ((348, 387), 'pytest.fixture', 'fixture', ([], {'autouse': '(True)', 'scope': '"""function"""'}), "(autouse=True, scope='function')\n", (355, 387), False, 'from pytest import fixture\n'), ((622, 659), 'sqlmodel.create_engine', 'create_engine', (['f"""sqlite:///{test_db}"""'], {}), "(f'sqlite:///{test_db}')\n", (635, 659), False, 'from sqlmodel import create_engine, SQLModel\n'), ((664, 700), 'sqlmodel.SQLModel.metadata.create_all', 'SQLModel.metadata.create_all', (['engine'], {}), '(engine)\n', (692, 700), False, 'from sqlmodel import create_engine, SQLModel\n'), ((710, 772), 'unittest.mock.patch', 'patch', (['"""mitmirror.infra.config.database_config.engine"""', 'engine'], {}), "('mitmirror.infra.config.database_config.engine', engine)\n", (715, 772), False, 'from unittest.mock import patch\n')]