tests: Make bases test classes in core

This commit is contained in:
Thomas Adamcik 2015-03-27 19:30:10 +01:00
parent 447629cbf9
commit f5f9899db9
2 changed files with 10 additions and 5 deletions

View File

@ -9,7 +9,7 @@ from mopidy import backend, core
from mopidy.models import Image, Ref, SearchResult, Track
class CoreLibraryTest(unittest.TestCase):
class BaseCoreLibraryTest(unittest.TestCase):
def setUp(self): # noqa: N802
dummy1_root = Ref.directory(uri='dummy1:directory', name='dummy1')
self.backend1 = mock.Mock()
@ -38,6 +38,9 @@ class CoreLibraryTest(unittest.TestCase):
self.core = core.Core(mixer=None, backends=[
self.backend1, self.backend2, self.backend3])
# TODO: split by method
class CoreLibraryTest(BaseCoreLibraryTest):
def test_get_images_returns_empty_dict_for_no_uris(self):
self.assertEqual({}, self.core.library.get_images([]))
@ -288,15 +291,15 @@ class CoreLibraryTest(unittest.TestCase):
query={'any': ['foobar']}, uris=None, exact=False)
class DeprecatedCoreLibraryTest(CoreLibraryTest):
class DeprecatedFindExactCoreLibraryTest(BaseCoreLibraryTest):
def setUp(self): # noqa: N802
super(DeprecatedCoreLibraryTest, self).setUp()
super(DeprecatedFindExactCoreLibraryTest, self).setUp()
self._warnings_filters = warnings.filters
warnings.filters = warnings.filters[:]
warnings.filterwarnings('ignore', '.*library.find_exact.*')
def tearDown(self): # noqa: N802
super(DeprecatedCoreLibraryTest, self).tearDown()
super(DeprecatedFindExactCoreLibraryTest, self).tearDown()
warnings.filters = self._warnings_filters
def test_find_exact_combines_results_from_all_backends(self):

View File

@ -9,7 +9,7 @@ from mopidy import backend, core
from mopidy.models import Playlist, Ref, Track
class PlaylistsTest(unittest.TestCase):
class BasePlaylistsTest(unittest.TestCase):
def setUp(self): # noqa: N802
self.plr1a = Ref.playlist(name='A', uri='dummy1:pl:a')
self.plr1b = Ref.playlist(name='B', uri='dummy1:pl:b')
@ -50,6 +50,8 @@ class PlaylistsTest(unittest.TestCase):
self.core = core.Core(mixer=None, backends=[
self.backend3, self.backend1, self.backend2])
class PlaylistTest(BasePlaylistsTest):
def test_as_list_combines_result_from_backends(self):
result = self.core.playlists.as_list()