diff --git a/larigira/audiogen_mpdrandom.py b/larigira/audiogen_mpdrandom.py index 8503cc6..5f12d3c 100644 --- a/larigira/audiogen_mpdrandom.py +++ b/larigira/audiogen_mpdrandom.py @@ -7,10 +7,7 @@ from mpd import MPDClient def generate_by_artist(spec): '''choose HOWMANY random artists, and for each one choose a random song''' - for attr in ('howmany',): - if attr not in spec: - raise ValueError("Malformed audiospec: missing '%s'" % attr) - + spec.setdefault('howmany', 1) log.info('generating') c = MPDClient() c.connect('localhost', 6600) # TODO: read global options somehow diff --git a/larigira/audiogen_randomdir.py b/larigira/audiogen_randomdir.py index f31bf7d..63d9bb9 100644 --- a/larigira/audiogen_randomdir.py +++ b/larigira/audiogen_randomdir.py @@ -24,7 +24,8 @@ def generate(spec): - paths [mandatory] list of source paths - howmany [mandatory] number of audio files to pick ''' - for attr in ('paths', 'howmany'): + spec.setdefault('howmany', 1) + for attr in ('paths', ): if attr not in spec: raise ValueError("Malformed audiospec: missing '%s'" % attr) diff --git a/larigira/tests/test_audiogen_mpdrandom.py b/larigira/tests/test_audiogen_mpdrandom.py new file mode 100644 index 0000000..4301ea4 --- /dev/null +++ b/larigira/tests/test_audiogen_mpdrandom.py @@ -0,0 +1,18 @@ +from __future__ import print_function +from gevent import monkey +monkey.patch_all(subprocess=True) + +import pytest + +from larigira.audiogen_mpdrandom import generate_by_artist + + +@pytest.fixture +def simplerandom(): + return { + } + + +def test_accepted_syntax(simplerandom): + '''Check the minimal needed configuration for mpdrandom''' + generate_by_artist(simplerandom) diff --git a/larigira/tests/test_audiogen_randomdir.py b/larigira/tests/test_audiogen_randomdir.py new file mode 100644 index 0000000..28f6e6a --- /dev/null +++ b/larigira/tests/test_audiogen_randomdir.py @@ -0,0 +1,19 @@ +from __future__ import print_function +from gevent import monkey +monkey.patch_all(subprocess=True) + +import pytest + +from larigira.audiogen_randomdir import generate + + +@pytest.fixture +def simplerandom(): + return { + 'paths': '/tmp/do/not/exist', + } + + +def test_accepted_syntax(simplerandom): + '''Check the minimal needed configuration for randomdir''' + generate(simplerandom)