sidebar: Add the Genre section to the sidebar
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
0f2a5aee9d
commit
f8494cf47b
|
@ -3,6 +3,7 @@
|
|||
from gi.repository import GObject
|
||||
from gi.repository import Gtk
|
||||
from . import artist
|
||||
from . import genre
|
||||
from . import playlist
|
||||
from . import section
|
||||
from .. import db
|
||||
|
@ -23,11 +24,12 @@ class Card(Gtk.Box):
|
|||
self._filter = entry.Filter("playlists")
|
||||
self._playlists = playlist.Section(self.sql.playlists)
|
||||
self._artists = artist.Section(self.sql.artists, self.sql.albums)
|
||||
self._genres = genre.Section(self.sql.genres)
|
||||
self._group = section.Group(sql)
|
||||
|
||||
self.append(self._filter)
|
||||
|
||||
for sect in [self._playlists, self._artists]:
|
||||
for sect in [self._playlists, self._artists, self._genres]:
|
||||
self.append(sect)
|
||||
self._group.add(sect)
|
||||
|
||||
|
@ -60,6 +62,8 @@ class Card(Gtk.Box):
|
|||
section = self._playlists
|
||||
case self.sql.artists | self.sql.albums | self.sql.media:
|
||||
section = self._artists
|
||||
case self.sql.genres:
|
||||
section = self._genres
|
||||
|
||||
section.active = True
|
||||
section.select_playlist(playlist)
|
||||
|
|
|
@ -80,7 +80,8 @@ class TestSidebar(tests.util.TestCase):
|
|||
|
||||
self.assertListEqual(self.sidebar._group._sections,
|
||||
[self.sidebar._playlists,
|
||||
self.sidebar._artists])
|
||||
self.sidebar._artists,
|
||||
self.sidebar._genres])
|
||||
|
||||
def test_sections(self):
|
||||
"""Tests sidebar section models."""
|
||||
|
@ -88,15 +89,20 @@ class TestSidebar(tests.util.TestCase):
|
|||
emmental.sidebar.playlist.Section)
|
||||
self.assertIsInstance(self.sidebar._artists,
|
||||
emmental.sidebar.artist.Section)
|
||||
self.assertIsInstance(self.sidebar._genres,
|
||||
emmental.sidebar.genre.Section)
|
||||
|
||||
self.assertEqual(self.sidebar._filter.get_next_sibling(),
|
||||
self.sidebar._playlists)
|
||||
self.assertEqual(self.sidebar._playlists.get_next_sibling(),
|
||||
self.sidebar._artists)
|
||||
self.assertEqual(self.sidebar._artists.get_next_sibling(),
|
||||
self.sidebar._genres)
|
||||
|
||||
self.assertEqual(self.sidebar._playlists.table, self.sql.playlists)
|
||||
self.assertEqual(self.sidebar._artists.table, self.sql.artists)
|
||||
self.assertEqual(self.sidebar._artists.album_table, self.sql.albums)
|
||||
self.assertEqual(self.sidebar._genres.table, self.sql.genres)
|
||||
|
||||
def test_select_playlist(self):
|
||||
"""Test setting the active playlist."""
|
||||
|
@ -117,3 +123,8 @@ class TestSidebar(tests.util.TestCase):
|
|||
self.sidebar.select_playlist(plist)
|
||||
self.assertTrue(self.sidebar._artists.active)
|
||||
self.sidebar._artists.select_playlist.assert_called_with(plist)
|
||||
|
||||
genre = self.sql.genres.create("Test Genre")
|
||||
self.sidebar.select_playlist(genre)
|
||||
self.assertTrue(self.sidebar._genres.active)
|
||||
self.assertEqual(self.sidebar.selected_playlist, genre)
|
||||
|
|
Loading…
Reference in New Issue