audiogen has default howmany=1
This commit is contained in:
parent
74579a20a9
commit
05144d0c2f
4 changed files with 40 additions and 5 deletions
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
|
|
18
larigira/tests/test_audiogen_mpdrandom.py
Normal file
18
larigira/tests/test_audiogen_mpdrandom.py
Normal 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)
|
19
larigira/tests/test_audiogen_randomdir.py
Normal file
19
larigira/tests/test_audiogen_randomdir.py
Normal 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)
|
Loading…
Reference in a new issue