From f526b42d657b589bebf86b64c86ad1b6dbf4aacb Mon Sep 17 00:00:00 2001 From: evilchili Date: Sat, 17 Dec 2022 12:49:08 -0800 Subject: [PATCH] ensure in-memory db mock is used --- test/conftest.py | 9 +++++++-- test/fixtures/themes/default_theme/console.cfg | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/themes/default_theme/console.cfg diff --git a/test/conftest.py b/test/conftest.py index 5ac874f..94f618a 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -10,6 +10,8 @@ from groove.playlist import Playlist from sqlalchemy import create_engine, insert from sqlalchemy.orm import sessionmaker +from unittest.mock import MagicMock + @pytest.fixture(autouse=True, scope='function') def env(): @@ -26,8 +28,11 @@ def auth(): @pytest.fixture(scope='function') -def in_memory_engine(): - return create_engine('sqlite:///:memory:', future=True) +def in_memory_engine(monkeypatch): + engine = create_engine('sqlite:///:memory:', future=True) + monkeypatch.setattr('groove.db.manager.create_engine', + MagicMock(return_value=engine)) + return engine @pytest.fixture(scope='function') diff --git a/test/fixtures/themes/default_theme/console.cfg b/test/fixtures/themes/default_theme/console.cfg new file mode 100644 index 0000000..9063efe --- /dev/null +++ b/test/fixtures/themes/default_theme/console.cfg @@ -0,0 +1,12 @@ +[styles] +text = #999999 +bright = #f1f2f6 +bold = #f1f2f6 bold +dim = #555555 +link = #9999FF +prompt = #f1f2f6 bold +artist = #017D93 +title = #70bc45 +help = #999999 +background = #001321 +error = #FF8888