def test_print_verbose_status_typical(self): dbus.mock_method('/TrackList', 'GetLength', lambda: 4) dbus.mock_method('/Player', 'GetStatus', lambda: [0, 1, 0, 1]) dbus.mock_method('/TrackList', 'GetCurrentTrack', lambda: 2) dbus.mock_method('/Player', 'PositionGet', lambda: 89147) dbus.mock_method( '/Player', 'GetMetadata', lambda: { 'audio-bitrate': 289671, 'time': 143, 'mtime': 143201, 'album': 'This is the Album', 'artist': 'An Artist', 'date': '1997', 'length': 143201, 'location': 'file:///home/me/Music/An%20Artist/This%20is%20the%20Album%20I_%201974-1980/An Artist%20-%2003%20-%20Yeah%20Whatever.mp3', 'title': 'Yeah Whatever', 'trackid': '00000000-1111-2222-3333-444444444444', 'tracknumber': '3', }) expected_output = ('[playing 3/4] @ 1:29/2:23 - #3\n' ' artist: An Artist\n' ' title: Yeah Whatever\n' ' album: This is the Album\n' '[repeat off] [random on] [loop on]\n') r = mprisremote.MPRISRemote() r.find_player('foo') self.assertEquals(expected_output, r.verbose_status())
def test_playstatus(self): dbus.mock_method('/Player', 'GetStatus', lambda: [0, 1, 0, 1]) expected_output = ("playing: playing\n" + "random/shuffle: true\n" + "repeat track: false\n" + "repeat list: true\n") r = mprisremote.MPRISRemote() r.find_player('foo') self.assertEquals(expected_output, ''.join(r.playstatus()))
def test_trackinfo(self): dbus.mock_method('/Player', 'GetMetadata', lambda: { 'a': 'b', 'c': 1000 }) expected_output = 'a: b\nc: 1000\n' r = mprisremote.MPRISRemote() r.find_player('foo') self.assertEquals(expected_output, ''.join(r.trackinfo()))
def test_trackinfo_with_track_number(self): dbus.mock_method('/TrackList', 'GetLength', lambda: 9) dbus.mock_method('/TrackList', 'GetMetadata', lambda tracknum: { 'a': 'b', 'c': tracknum }) expected_output = 'a: b\nc: 8\n' r = mprisremote.MPRISRemote() r.find_player('foo') self.assertEquals(expected_output, ''.join(r.trackinfo('8')))
def test_loop_get_false(self): dbus.mock_method('/Player', 'GetStatus', lambda: [0, 0, 0, 0]) r = mprisremote.MPRISRemote() r.find_player('foo') self.assertEquals('false\n', ''.join(r.loop()))
def test_random_get_true(self): dbus.mock_method('/Player', 'GetStatus', lambda: [0, 1, 0, 0]) r = mprisremote.MPRISRemote() r.find_player('foo') self.assertEquals('true\n', ''.join(r.random()))