fixing tests
This commit is contained in:
parent
5ff2c39542
commit
9eb5f009e6
|
@ -14,9 +14,6 @@ from sqlalchemy.orm.session import Session
|
||||||
from sqlalchemy.engine.row import Row
|
from sqlalchemy.engine.row import Row
|
||||||
from sqlalchemy.exc import NoResultFound, MultipleResultsFound
|
from sqlalchemy.exc import NoResultFound, MultipleResultsFound
|
||||||
|
|
||||||
from rich.table import Table, Column
|
|
||||||
from rich import box
|
|
||||||
|
|
||||||
from yaml.scanner import ScannerError
|
from yaml.scanner import ScannerError
|
||||||
|
|
||||||
|
|
||||||
|
|
4
test/fixtures/env
vendored
4
test/fixtures/env
vendored
|
@ -22,3 +22,7 @@ MEDIA_GLOB=*.mp3,*.flac,*.m4a
|
||||||
|
|
||||||
# Set this value to enable debugging
|
# Set this value to enable debugging
|
||||||
DEBUG=1
|
DEBUG=1
|
||||||
|
|
||||||
|
EDITOR=ed
|
||||||
|
CONSOLE_THEMES=True
|
||||||
|
CONSOLE_WIDTH=80
|
||||||
|
|
|
@ -132,7 +132,7 @@ def test_playlist_inequality_tracks_differ(db):
|
||||||
def test_as_yaml(db):
|
def test_as_yaml(db):
|
||||||
expected = {
|
expected = {
|
||||||
'playlist one': {
|
'playlist one': {
|
||||||
'description': 'the first one',
|
'description': 'the first one\n',
|
||||||
'entries': [
|
'entries': [
|
||||||
{'UNKLE': 'Guns Blazing'},
|
{'UNKLE': 'Guns Blazing'},
|
||||||
{'UNKLE': 'UNKLE'},
|
{'UNKLE': 'UNKLE'},
|
||||||
|
|
|
@ -6,7 +6,7 @@ from unittest.mock import MagicMock
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def cmd_prompt(in_memory_engine, db):
|
def cmd_prompt(monkeypatch, in_memory_engine, db):
|
||||||
with database_manager() as manager:
|
with database_manager() as manager:
|
||||||
manager._session = db
|
manager._session = db
|
||||||
yield interactive_shell.CommandPrompt(manager)
|
yield interactive_shell.CommandPrompt(manager)
|
||||||
|
@ -20,7 +20,7 @@ def response_factory(responses):
|
||||||
(['stats'], 'Database contains 4 playlists'), # match the db fixture
|
(['stats'], 'Database contains 4 playlists'), # match the db fixture
|
||||||
])
|
])
|
||||||
def test_stats(monkeypatch, capsys, cmd_prompt, inputs, expected):
|
def test_stats(monkeypatch, capsys, cmd_prompt, inputs, expected):
|
||||||
monkeypatch.setattr('groove.shell.base.prompt', response_factory(inputs))
|
monkeypatch.setattr('groove.console.Console.prompt', response_factory(inputs))
|
||||||
cmd_prompt.start()
|
cmd_prompt.start()
|
||||||
output = capsys.readouterr()
|
output = capsys.readouterr()
|
||||||
assert expected in output.out
|
assert expected in output.out
|
||||||
|
@ -30,13 +30,13 @@ def test_stats(monkeypatch, capsys, cmd_prompt, inputs, expected):
|
||||||
(['quit'], SystemExit),
|
(['quit'], SystemExit),
|
||||||
])
|
])
|
||||||
def test_quit(monkeypatch, capsys, cmd_prompt, inputs, expected):
|
def test_quit(monkeypatch, capsys, cmd_prompt, inputs, expected):
|
||||||
monkeypatch.setattr('groove.shell.base.prompt', response_factory(inputs))
|
monkeypatch.setattr('groove.console.Console.prompt', response_factory(inputs))
|
||||||
with pytest.raises(expected):
|
with pytest.raises(expected):
|
||||||
cmd_prompt.start()
|
cmd_prompt.start()
|
||||||
|
|
||||||
|
|
||||||
def test_browse(monkeypatch, capsys, cmd_prompt):
|
def test_browse(monkeypatch, capsys, cmd_prompt):
|
||||||
monkeypatch.setattr('groove.shell.base.prompt', response_factory(['browse']))
|
monkeypatch.setattr('groove.console.Console.prompt', response_factory(['browse']))
|
||||||
cmd_prompt.start()
|
cmd_prompt.start()
|
||||||
output = capsys.readouterr()
|
output = capsys.readouterr()
|
||||||
assert 'Displaying 4 playlists' in output.out
|
assert 'Displaying 4 playlists' in output.out
|
||||||
|
@ -49,11 +49,11 @@ def test_browse(monkeypatch, capsys, cmd_prompt):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('inputs, expected', [
|
@pytest.mark.parametrize('inputs, expected', [
|
||||||
('help', ['Available Commands', ' help ', ' stats ', ' browse ']),
|
(['help'], ['Available Commands', ' help ', ' stats ', ' browse ']),
|
||||||
('help browse', ['Help for browse']),
|
(['help browse'], ['Help for browse']),
|
||||||
])
|
])
|
||||||
def test_help(monkeypatch, capsys, cmd_prompt, inputs, expected):
|
def test_help(monkeypatch, capsys, cmd_prompt, inputs, expected):
|
||||||
monkeypatch.setattr('groove.shell.base.prompt', response_factory([inputs]))
|
monkeypatch.setattr('groove.console.Console.prompt', response_factory(inputs))
|
||||||
cmd_prompt.start()
|
cmd_prompt.start()
|
||||||
output = capsys.readouterr()
|
output = capsys.readouterr()
|
||||||
for txt in expected:
|
for txt in expected:
|
||||||
|
@ -62,12 +62,12 @@ def test_help(monkeypatch, capsys, cmd_prompt, inputs, expected):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('inputs, expected', [
|
@pytest.mark.parametrize('inputs, expected', [
|
||||||
('load A New Playlist', 'a-new-playlist'),
|
(['load A New Playlist'], 'a-new-playlist'),
|
||||||
('new playlist', 'new-playlist'),
|
(['new playlist'], 'new-playlist'),
|
||||||
('load', '')
|
(['load'], '')
|
||||||
])
|
])
|
||||||
def test_load(monkeypatch, caplog, cmd_prompt, inputs, expected):
|
def test_load(monkeypatch, caplog, cmd_prompt, inputs, expected):
|
||||||
monkeypatch.setattr('groove.shell.base.prompt', response_factory([inputs]))
|
monkeypatch.setattr('groove.console.Console.prompt', response_factory(inputs))
|
||||||
cmd_prompt.start()
|
cmd_prompt.start()
|
||||||
assert expected in caplog.text
|
assert expected in caplog.text
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user