47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
# Copyright 2022 (c) Anna Schumaker.
|
|
"""Tests our Now Playing card."""
|
|
import unittest
|
|
import emmental
|
|
from gi.repository import Gtk
|
|
|
|
|
|
class TestNowPlaying(unittest.TestCase):
|
|
"""Test case for our custom Now Playing card."""
|
|
|
|
def setUp(self):
|
|
"""Set up common variables."""
|
|
self.card = emmental.nowplaying.Card()
|
|
|
|
def test_init(self):
|
|
"""Test that the card has been initialized correctly."""
|
|
self.assertIsInstance(self.card, Gtk.Box)
|
|
self.assertIsInstance(self.card._grid, Gtk.Grid)
|
|
|
|
self.assertEqual(self.card.get_last_child(), self.card._grid)
|
|
self.assertTrue(self.card.has_css_class("card"))
|
|
|
|
def test_prefer_artist(self):
|
|
"""Test the 'prefer-artist' property."""
|
|
self.assertTrue(self.card.prefer_artist)
|
|
|
|
self.card.prefer_artist = False
|
|
self.assertFalse(self.card.prefer_artist)
|
|
self.assertFalse(self.card._tags.prefer_artist)
|
|
|
|
self.card._tags.prefer_artist = True
|
|
self.assertTrue(self.card.prefer_artist)
|
|
self.assertTrue(self.card._tags.prefer_artist)
|
|
|
|
def test_tags(self):
|
|
"""Test tag properties."""
|
|
self.assertIsInstance(self.card._tags,
|
|
emmental.nowplaying.tags.TagInfo)
|
|
self.assertEqual(self.card._grid.get_child_at(0, 0), self.card._tags)
|
|
|
|
for tag in ["title", "album", "artist", "album-artist"]:
|
|
with self.subTest(tag=tag):
|
|
self.card.set_property(tag, f"test {tag}")
|
|
self.assertEqual(self.card.get_property(tag), f"test {tag}")
|
|
self.assertEqual(self.card._tags.get_property(tag),
|
|
f"test {tag}")
|