mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(db): remove unnecessary fixture declaration
Also revert the change to `conftest.py` in which the file was flagged for pytest to crawl for fixtures.
This commit is contained in:
parent
2cdda1fda2
commit
386b656530
@ -4,5 +4,3 @@
|
||||
# We import the model_installer and torch_device fixtures here so that they can be used by all tests. Flake8 does not
|
||||
# play well with fixtures (F401 and F811), so this is cleaner than importing in all files that use these fixtures.
|
||||
from invokeai.backend.util.test_utils import model_installer, torch_device # noqa: F401
|
||||
|
||||
pytest_plugins = ["tests.fixtures.sqlite_database"]
|
||||
|
31
tests/fixtures/sqlite_database.py
vendored
31
tests/fixtures/sqlite_database.py
vendored
@ -1,9 +1,6 @@
|
||||
from logging import Logger
|
||||
from typing import Callable
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from invokeai.app.services.config.config_default import InvokeAIAppConfig
|
||||
from invokeai.app.services.image_files.image_files_base import ImageFileStorageBase
|
||||
from invokeai.app.services.shared.sqlite.sqlite_database import SqliteDatabase
|
||||
@ -11,23 +8,17 @@ from invokeai.app.services.shared.sqlite_migrator.migrations.migration_1 import
|
||||
from invokeai.app.services.shared.sqlite_migrator.migrations.migration_2 import migration_2
|
||||
from invokeai.app.services.shared.sqlite_migrator.sqlite_migrator_impl import SQLiteMigrator
|
||||
|
||||
CreateSqliteDatabaseFunction = Callable[[InvokeAIAppConfig, Logger], SqliteDatabase]
|
||||
|
||||
def create_sqlite_database(config: InvokeAIAppConfig, logger: Logger) -> SqliteDatabase:
|
||||
db_path = None if config.use_memory_db else config.db_path
|
||||
db = SqliteDatabase(db_path=db_path, logger=logger, verbose=config.log_sql)
|
||||
|
||||
@pytest.fixture
|
||||
def create_sqlite_database() -> CreateSqliteDatabaseFunction:
|
||||
def _create_sqlite_database(config: InvokeAIAppConfig, logger: Logger) -> SqliteDatabase:
|
||||
db_path = None if config.use_memory_db else config.db_path
|
||||
db = SqliteDatabase(db_path=db_path, logger=logger, verbose=config.log_sql)
|
||||
image_files = mock.Mock(spec=ImageFileStorageBase)
|
||||
|
||||
image_files = mock.Mock(spec=ImageFileStorageBase)
|
||||
|
||||
migrator = SQLiteMigrator(db=db)
|
||||
migration_2.provide_dependency("logger", logger)
|
||||
migration_2.provide_dependency("image_files", image_files)
|
||||
migrator.register_migration(migration_1)
|
||||
migrator.register_migration(migration_2)
|
||||
migrator.run_migrations()
|
||||
return db
|
||||
|
||||
return _create_sqlite_database
|
||||
migrator = SQLiteMigrator(db=db)
|
||||
migration_2.provide_dependency("logger", logger)
|
||||
migration_2.provide_dependency("image_files", image_files)
|
||||
migrator.register_migration(migration_1)
|
||||
migrator.register_migration(migration_2)
|
||||
migrator.run_migrations()
|
||||
return db
|
||||
|
Loading…
Reference in New Issue
Block a user