diff --git a/emmental/sidebar/row.py b/emmental/sidebar/row.py new file mode 100644 index 0000000..7776891 --- /dev/null +++ b/emmental/sidebar/row.py @@ -0,0 +1,13 @@ +# Copyright 2022 (c) Anna Schumaker. +"""Widgets for sidebar rows.""" +from gi.repository import GObject +from gi.repository import Gtk +from .. import db + + +class BaseRow(Gtk.Box): + """Base class for Row widgets.""" + + playlist = GObject.Property(type=db.playlist.Playlist) + name = GObject.Property(type=str) + count = GObject.Property(type=int) diff --git a/tests/sidebar/test_row.py b/tests/sidebar/test_row.py new file mode 100644 index 0000000..6f85060 --- /dev/null +++ b/tests/sidebar/test_row.py @@ -0,0 +1,40 @@ +# Copyright 2022 (c) Anna Schumaker. +"""Tests our sidebar row widgets.""" +import unittest +import emmental.sidebar.row +from gi.repository import Gio +from gi.repository import Gtk + + +class TestBaseRow(unittest.TestCase): + """Test our BaseRow class.""" + + def setUp(self): + """Set up common variables.""" + self.row = emmental.sidebar.row.BaseRow() + + def test_init(self): + """Test that the BaseRow is configured correctly.""" + self.assertIsInstance(self.row, Gtk.Box) + self.assertEqual(self.row.get_orientation(), + Gtk.Orientation.HORIZONTAL) + + def test_name(self): + """Test the name property.""" + self.assertEqual(self.row.name, "") + row2 = emmental.sidebar.row.BaseRow(name="Test Playlist") + self.assertEqual(row2.name, "Test Playlist") + + def test_count(self): + """Test the count property.""" + self.assertEqual(self.row.count, 0) + row2 = emmental.sidebar.row.BaseRow(count=42) + self.assertEqual(row2.count, 42) + + def test_playlist(self): + """Test the playlist property.""" + plist = emmental.db.playlist.Playlist(Gio.ListStore(), + 0, "Playlist Name") + self.assertIsNone(self.row.playlist) + row2 = emmental.sidebar.row.BaseRow(playlist=plist) + self.assertEqual(row2.playlist, plist)