tests and bug fixes

This commit is contained in:
evilchili
2022-12-07 23:41:49 -08:00
parent af33e91232
commit 228d44ce98
7 changed files with 48 additions and 23 deletions
View File
+26 -3
View File
@@ -2,12 +2,35 @@ import pytest
import os
from groove import path
from groove.exceptions import ConfigurationError
from groove.exceptions import ConfigurationError, ThemeMissingException
from groove.webserver import themes
def test_missing_theme_root(monkeypatch):
@pytest.mark.parametrize('root', ['/dev/null/missing', None])
def test_missing_media_root(monkeypatch, root):
broken_env = {k: v for (k, v) in os.environ.items()}
broken_env['GROOVE_ON_DEMAND_ROOT'] = '/dev/null/missing'
broken_env['MEDIA_ROOT'] = root
monkeypatch.setattr(os, 'environ', broken_env)
with pytest.raises(ConfigurationError):
path.media_root()
def test_static(monkeypatch):
assert path.static('foo')
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):
broken_env = {k: v for (k, v) in os.environ.items()}
broken_env['GROOVE_ON_DEMAND_ROOT'] = root
monkeypatch.setattr(os, 'environ', broken_env)
with pytest.raises(ConfigurationError):
path.themes_root()
def test_theme_no_path():
with pytest.raises(ThemeMissingException):
path.theme('nope')
def test_database(env):
assert env['DATABASE_PATH'] in path.database().name
-2
View File
@@ -6,8 +6,6 @@ from unittest.mock import MagicMock
from groove import playlist, editor
from groove.exceptions import PlaylistValidationError, TrackNotFoundError
# 166-167, 200, 203-204, 227-228, 253->255, 255->exit, 270, 346-347
def test_create(empty_playlist):
assert empty_playlist.record.id
+6
View File
@@ -58,6 +58,7 @@ def test_help(monkeypatch, capsys, cmd_prompt, inputs, expected):
output = capsys.readouterr()
for txt in expected:
assert txt in output.out
assert cmd_prompt.__doc__ == cmd_prompt.help_text
@pytest.mark.parametrize('inputs, expected', [
@@ -69,3 +70,8 @@ def test_load(monkeypatch, caplog, cmd_prompt, inputs, expected):
monkeypatch.setattr('groove.shell.base.prompt', response_factory([inputs]))
cmd_prompt.start()
assert expected in caplog.text
def test_values(cmd_prompt):
for cmd in [cmd for cmd in cmd_prompt.commands.keys() if not cmd.startswith('_')]:
assert cmd in cmd_prompt.values