ext: Replace validate_config() with get_config_schema()
This commit is contained in:
parent
28096ce259
commit
12ff51ceba
@ -1,5 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from mopidy.utils import config
|
||||
|
||||
|
||||
class Extension(object):
|
||||
|
||||
@ -10,9 +12,8 @@ class Extension(object):
|
||||
raise NotImplementedError(
|
||||
'Add at least a config section with "enabled = true"')
|
||||
|
||||
def validate_config(self, config):
|
||||
raise NotImplementedError(
|
||||
'You must explicitly pass config validation if not needed')
|
||||
def get_config_schema(self):
|
||||
return config.ExtensionConfigSchema()
|
||||
|
||||
def validate_environment(self):
|
||||
pass
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from mopidy.ext import Extension
|
||||
from mopidy.utils import config
|
||||
|
||||
from tests import unittest
|
||||
|
||||
@ -18,8 +19,10 @@ class ExtensionTest(unittest.TestCase):
|
||||
def test_get_default_config_raises_not_implemented(self):
|
||||
self.assertRaises(NotImplementedError, self.ext.get_default_config)
|
||||
|
||||
def test_validate_config_raises_not_implemented(self):
|
||||
self.assertRaises(NotImplementedError, self.ext.validate_config, None)
|
||||
def test_get_config_schema_returns_extension_schema(self):
|
||||
schema = self.ext.get_config_schema()
|
||||
self.assertIsInstance(schema, config.ExtensionConfigSchema)
|
||||
self.assertIsInstance(schema['enabled'], config.Boolean)
|
||||
|
||||
def test_validate_environment_does_nothing_by_default(self):
|
||||
self.assertIsNone(self.ext.validate_environment())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user