tests and bug fixes
This commit is contained in:
+26
-3
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user