-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add extension superclass and exception #372
Merged
adamcik
merged 4 commits into
mopidy:develop
from
jodal:feature/add-extension-superclass
Apr 1, 2013
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from __future__ import unicode_literals | ||
|
||
|
||
class Extension(object): | ||
|
||
name = None | ||
version = None | ||
|
||
def get_default_config(self): | ||
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 validate_environment(self): | ||
pass | ||
|
||
def get_frontend_class(self): | ||
pass | ||
|
||
def get_backend_class(self): | ||
pass | ||
|
||
def register_gstreamer_elements(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from __future__ import unicode_literals | ||
|
||
from mopidy import exceptions | ||
|
||
from tests import unittest | ||
|
||
|
||
class ExceptionsTest(unittest.TestCase): | ||
def test_exception_can_include_message_string(self): | ||
exc = exceptions.MopidyException('foo') | ||
|
||
self.assertEqual(exc.message, 'foo') | ||
self.assertEqual(str(exc), 'foo') | ||
|
||
def test_settings_error_is_a_mopidy_exception(self): | ||
self.assert_(issubclass( | ||
exceptions.SettingsError, exceptions.MopidyException)) | ||
|
||
def test_optional_dependency_error_is_a_mopidy_exception(self): | ||
self.assert_(issubclass( | ||
exceptions.OptionalDependencyError, exceptions.MopidyException)) | ||
|
||
def test_extension_error_is_a_mopidy_exception(self): | ||
self.assert_(issubclass( | ||
exceptions.ExtensionError, exceptions.MopidyException)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from __future__ import unicode_literals | ||
|
||
from mopidy.ext import Extension | ||
|
||
from tests import unittest | ||
|
||
|
||
class ExtensionTest(unittest.TestCase): | ||
def setUp(self): | ||
self.ext = Extension() | ||
|
||
def test_name_is_none(self): | ||
self.assertIsNone(self.ext.name) | ||
|
||
def test_version_is_none(self): | ||
self.assertIsNone(self.ext.version) | ||
|
||
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_validate_environment_does_nothing_by_default(self): | ||
self.assertIsNone(self.ext.validate_environment()) | ||
|
||
def test_get_frontend_class_returns_none_by_default(self): | ||
self.assertIsNone(self.ext.get_frontend_class()) | ||
|
||
def test_get_backend_class_returns_none_by_default(self): | ||
self.assertIsNone(self.ext.get_backend_class()) | ||
|
||
def test_register_gstreamer_elements_does_nothing_by_default(self): | ||
self.assertIsNone(self.ext.register_gstreamer_elements()) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/class/classes/ perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple frontends in a single extension? Why not. A lot more future proof.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.