settings: Fail if BACKENDS/FRONTENDS setting isn't iterable (fixes #278)
This commit is contained in:
parent
8fcc7966b2
commit
5d707e3918
@ -8,6 +8,15 @@ This change log is used to track all major changes to Mopidy.
|
||||
v0.11.0 (in development)
|
||||
========================
|
||||
|
||||
**Settings**
|
||||
|
||||
- The settings validator now complains if a setting which expects a tuple of
|
||||
values (e.g. :attr:`mopidy.settings.BACKENDS`,
|
||||
:attr:`mopidy.settings.FRONTENDS`) has a non-iterable value. This typically
|
||||
happens because the setting value contains a single value and one has
|
||||
forgotten to add a comma after the string, making the value a tuple. (Fixes:
|
||||
:issue:`278`)
|
||||
|
||||
**Spotify backend**
|
||||
|
||||
- Add :attr:`mopidy.settings.SPOTIFY_TIMEOUT` setting which allows you to
|
||||
|
||||
@ -172,6 +172,10 @@ def validate_settings(defaults, settings):
|
||||
'bin in OUTPUT.')
|
||||
|
||||
elif setting in list_of_one_or_more:
|
||||
if not hasattr(value, '__iter__'):
|
||||
errors[setting] = (
|
||||
'Must be a tuple. '
|
||||
"Remember the comma after single values: (u'value',)")
|
||||
if not value:
|
||||
errors[setting] = 'Must contain at least one value.'
|
||||
|
||||
|
||||
@ -87,6 +87,14 @@ class ValidateSettingsTest(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
result['BACKENDS'], 'Must contain at least one value.')
|
||||
|
||||
def test_noniterable_multivalue_setting_returns_error(self):
|
||||
result = setting_utils.validate_settings(
|
||||
self.defaults, {'FRONTENDS': ('this is not a tuple')})
|
||||
self.assertEqual(
|
||||
result['FRONTENDS'],
|
||||
'Must be a tuple. '
|
||||
"Remember the comma after single values: (u'value',)")
|
||||
|
||||
|
||||
class SettingsProxyTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user