1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
import unittest
import deckit.modules.music as music
class Music(unittest.TestCase):
def test_parses_metadata(self):
sep = "\x1f"
fake = lambda cmd, timeout=2: {
"metadata": sep.join(["Playing", "Song", "Artist", "Album", "200000000",
"1000000", "", "spotify"]),
"get-volume": "Volume: 0.42",
}[cmd[1]]
m = music.make({"run": fake})
st = m.state()
self.assertEqual(st["title"], "Song")
self.assertEqual(st["status"], "Playing")
self.assertEqual(st["volume"]["level"], 42)
def test_action_commands(self):
self.assertEqual(music.BASE_ACTIONS["next"], ["playerctl", "next"])
if __name__ == "__main__":
unittest.main()
|