mopidy/tests/exceptions_test.py
Stein Magnus Jodal 65f14a9cc4 exc: Remove OptionalDependencyError
It is no longer needed as the extension loading mechanisms verifies the
environment and presence of dependencies before it tries to import modules that
would cause ImportErrors if optional dependencies are missing.
2013-04-14 11:26:16 +02:00

29 lines
965 B
Python

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_extension_error_is_a_mopidy_exception(self):
self.assert_(issubclass(
exceptions.ExtensionError, exceptions.MopidyException))
def test_config_error_is_a_mopidy_exception(self):
self.assert_(issubclass(
exceptions.ConfigError, exceptions.MopidyException))
def test_config_error_provides_getitem(self):
exception = exceptions.ConfigError(
{'field1': 'msg1', 'field2': 'msg2'})
self.assertEqual('msg1', exception['field1'])
self.assertEqual('msg2', exception['field2'])
self.assertItemsEqual(['field1', 'field2'], exception)