emmental/playlist/test_playlist.py
Anna Schumaker dbad19ad46 playlist: Create a new Panel class
Containing the ControlBox, PlaylistWindow, and FooterBox

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-26 17:26:09 -05:00

84 lines
3.2 KiB
Python

# Copyright 2021 (c) Anna Schumaker.
import db
import lib
import playlist
import unittest
from gi.repository import Gtk
class TestPanel(unittest.TestCase):
def test_init(self):
panel = playlist.Panel()
self.assertIsInstance(panel, Gtk.Box)
self.assertIsInstance(panel.header, playlist.header.Header)
self.assertIsInstance(panel.window, playlist.view.PlaylistWindow)
self.assertIsInstance(panel.footer, playlist.footer.Footer)
self.assertEqual(panel.get_orientation(), Gtk.Orientation.VERTICAL)
def test_items(self):
panel = playlist.Panel()
child = panel.get_first_child()
self.assertEqual(child, panel.header)
child = child.get_next_sibling()
self.assertIsInstance(child, Gtk.Separator)
child = child.get_next_sibling()
self.assertEqual(child, panel.window)
child = child.get_next_sibling()
self.assertIsInstance(child, Gtk.Separator)
child = child.get_next_sibling()
self.assertEqual(child, panel.footer)
def test_set_playlist(self):
collection = db.user.Table.find("Collection")
panel = playlist.Panel()
self.assertIsNone(panel.get_playlist())
panel.set_playlist(collection)
self.assertEqual(panel.header.get_last_child().get_first_child().playlist, collection)
self.assertEqual(panel.get_playlist(), collection)
class ColumnEV:
def __init__(self, title, width, expand):
self.title = title
self.width = width
self.expand = expand
columns = [ ColumnEV("#", -1, False),
ColumnEV("Title", 250, True),
ColumnEV("Length", -1, False),
ColumnEV("Artist", 150, False),
ColumnEV("Album", 150, False),
ColumnEV("Year", -1, False),
ColumnEV("Count", -1, False),
ColumnEV("Last Played", 150, False) ]
class TestPlaylist(unittest.TestCase):
def test_playlist_init(self):
self.assertIsInstance(playlist.Model, playlist.model.TagModel)
self.assertIsInstance(playlist.FilterModel, Gtk.FilterListModel)
self.assertIsInstance(playlist.Selection, Gtk.MultiSelection)
self.assertIsInstance(playlist.View, Gtk.ColumnView)
self.assertIsInstance(playlist.Scroll, Gtk.ScrolledWindow)
self.assertEqual(playlist.FilterModel.get_model(), playlist.Model)
self.assertEqual(playlist.FilterModel.get_filter(),
playlist.Model.Controls.filter)
self.assertEqual(playlist.Selection.get_model(), playlist.FilterModel)
self.assertEqual(playlist.View.get_model(), playlist.Selection)
self.assertEqual(playlist.Scroll.get_child(), playlist.View)
self.assertTrue(playlist.View.get_hexpand())
self.assertTrue(playlist.View.get_vexpand())
self.assertTrue(playlist.View.has_css_class("data-table"))
self.assertTrue(playlist.View.get_enable_rubberband())
for (i, c) in enumerate(playlist.View.get_columns()):
self.assertEqual(c.get_title(), columns[i].title)
self.assertEqual(c.get_fixed_width(), columns[i].width)
self.assertEqual(c.get_expand(), columns[i].expand)