fixing test env

This commit is contained in:
evilchili
2022-12-21 22:27:30 -08:00
parent 41a21671ca
commit 6b53b11f0e
6 changed files with 42 additions and 61 deletions
+2 -3
View File
@@ -14,12 +14,11 @@ from unittest.mock import MagicMock
@pytest.fixture(autouse=True, scope='function')
def env():
def env(monkeypatch):
root = Path(__file__).parent / Path('fixtures')
monkeypatch.setattr('groove.path.root', MagicMock(return_value=str(root)))
load_dotenv(Path('test/fixtures/env'))
os.environ['GROOVE_ON_DEMAND_ROOT'] = str(root)
os.environ['MEDIA_ROOT'] = str(root / Path('media'))
os.environ['DATABASE_PATH'] = ''
return os.environ
+2 -15
View File
@@ -1,25 +1,12 @@
# Will be overwritten by test setup
GROOVE_ON_DEMAND_ROOT=.
MEDIA_ROOT=.
# Admin user credentials
USERNAME=test_username
PASSWORD=test_password
# Web interface configuration
HOST=127.0.0.1
PORT=2323
THEMES_PATH=themes
STATIC_PATH=static
DEFAULT_THEME=default_theme
SECRET_KEY=fnord
# Media scanner configuration
MEDIA_GLOB=*.mp3,*.flac,*.m4a
# Set this value to enable debugging
DEBUG=1
EDITOR=ed
CONSOLE_THEMES=True
CONSOLE_WIDTH=80
DATABASE_PATH=
MEDIA_ROOT=
+2 -3
View File
@@ -20,10 +20,9 @@ def test_static(monkeypatch):
assert path.static('foo', theme=themes.load_theme('default_theme'))
@pytest.mark.parametrize('root', ['/dev/null/missing', None])
def test_missing_theme_root(monkeypatch, root):
def test_missing_theme_root(monkeypatch):
broken_env = {k: v for (k, v) in os.environ.items()}
broken_env['GROOVE_ON_DEMAND_ROOT'] = root
broken_env['THEMES_PATH'] = '/dev/null/enoexist'
monkeypatch.setattr(os, 'environ', broken_env)
with pytest.raises(ConfigurationError):
path.themes_root()