audiogen has default howmany=1

This commit is contained in:
boyska 2015-01-31 23:00:32 +01:00
parent 74579a20a9
commit 05144d0c2f
No known key found for this signature in database
GPG key ID: 7395DCAE58289CA9
4 changed files with 40 additions and 5 deletions

View file

@ -7,10 +7,7 @@ from mpd import MPDClient
def generate_by_artist(spec): def generate_by_artist(spec):
'''choose HOWMANY random artists, and for each one choose a random song''' '''choose HOWMANY random artists, and for each one choose a random song'''
for attr in ('howmany',): spec.setdefault('howmany', 1)
if attr not in spec:
raise ValueError("Malformed audiospec: missing '%s'" % attr)
log.info('generating') log.info('generating')
c = MPDClient() c = MPDClient()
c.connect('localhost', 6600) # TODO: read global options somehow c.connect('localhost', 6600) # TODO: read global options somehow

View file

@ -24,7 +24,8 @@ def generate(spec):
- paths [mandatory] list of source paths - paths [mandatory] list of source paths
- howmany [mandatory] number of audio files to pick - 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: if attr not in spec:
raise ValueError("Malformed audiospec: missing '%s'" % attr) raise ValueError("Malformed audiospec: missing '%s'" % attr)

View file

@ -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)

View file

@ -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)