2021-08-30 17:29:44 -04:00
|
|
|
# Copyright 2021 (c) Anna Schumaker.
|
|
|
|
import audio
|
2021-11-20 15:46:47 -05:00
|
|
|
import db
|
2021-09-06 13:12:40 -04:00
|
|
|
import pathlib
|
2021-08-30 17:29:44 -04:00
|
|
|
import unittest
|
2021-10-13 10:31:42 -04:00
|
|
|
from gi.repository import Gtk
|
2021-08-30 17:29:44 -04:00
|
|
|
|
2021-09-06 13:12:40 -04:00
|
|
|
test_album = pathlib.Path("./data/Test Album/")
|
2021-11-20 15:46:47 -05:00
|
|
|
test_track = test_album / "01 - Test Track.ogg"
|
2021-09-06 13:12:40 -04:00
|
|
|
|
2021-08-30 17:29:44 -04:00
|
|
|
class TestAudio(unittest.TestCase):
|
2021-10-13 10:31:42 -04:00
|
|
|
def test_init(self):
|
2021-08-30 17:29:44 -04:00
|
|
|
self.assertIsInstance(audio.Player, audio.player.Player)
|
|
|
|
|
2021-10-13 10:31:42 -04:00
|
|
|
def test_play_track(self):
|
2021-11-20 15:46:47 -05:00
|
|
|
db.reset()
|
|
|
|
track = db.make_fake_track(1, 10, "Test Track", test_track, test_album)
|
2021-09-06 13:12:40 -04:00
|
|
|
|
|
|
|
self.assertTrue(audio.play_track(track))
|
|
|
|
self.assertTrue(audio.Player.playing)
|
|
|
|
self.assertFalse(audio.play_track(track))
|
|
|
|
audio.Player.playing = False
|
|
|
|
|
2021-10-13 10:31:42 -04:00
|
|
|
def test_header(self):
|
|
|
|
header = audio.Header()
|
|
|
|
self.assertIsInstance(header, Gtk.HeaderBar)
|
|
|
|
self.assertIsInstance(header.get_title_widget(),
|
|
|
|
audio.nowplaying.NowPlaying)
|
|
|
|
|
|
|
|
def test_widgets(self):
|
2021-09-07 10:54:49 -04:00
|
|
|
self.assertIsInstance(audio.Artwork(),
|
|
|
|
audio.artwork.Artwork)
|