31 lines
1009 B
Python
31 lines
1009 B
Python
# Copyright 2021 (c) Anna Schumaker.
|
|
import datetime
|
|
import db
|
|
import playlist
|
|
import sidebar
|
|
import unittest
|
|
from gi.repository import Gtk
|
|
|
|
class TestSidebar(unittest.TestCase):
|
|
def test_init(self):
|
|
panel = playlist.Panel()
|
|
sbar = sidebar.Sidebar(panel)
|
|
self.assertIsInstance(sbar, Gtk.Box)
|
|
self.assertEqual(sbar.panel, panel)
|
|
|
|
child = sbar.get_first_child()
|
|
self.assertIsInstance(child, sidebar.stack.Switcher)
|
|
child = child.get_next_sibling()
|
|
self.assertIsInstance(child, sidebar.stack.Box)
|
|
|
|
def test_change_playlist(self):
|
|
artist = db.artist.Table.find("Test Artist", "Test Sort")
|
|
album = artist.find_album("Test Album", datetime.date(2021, 3, 18))
|
|
panel = playlist.Panel()
|
|
sbar = sidebar.Sidebar(panel)
|
|
|
|
sbar.playlist_changed(None, artist)
|
|
self.assertEqual(panel.get_playlist(), artist)
|
|
sbar.playlist_changed(None, album)
|
|
self.assertEqual(panel.get_playlist(), album)
|