Browse Source

audiogen has default howmany=1

boyska 9 years ago
parent
commit
05144d0c2f

+ 1 - 4
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

+ 2 - 1
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)
 

+ 18 - 0
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)

+ 19 - 0
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)