Esempio n. 1
0
 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()))
Esempio n. 2
0
 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())
Esempio n. 3
0
 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()))
Esempio n. 4
0
 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')))
Esempio n. 5
0
 def test_print_verbose_status_nothing(self):
     r = mprisremote.MPRISRemote()
     r.find_player('foo')
     self.assertEquals('', r.verbose_status())
Esempio n. 6
0
 def test_find_player_none_running(self):
     dbus.start_mocking(None)
     r = mprisremote.MPRISRemote()
     self.assertRaises(mprisremote.NoPlayersRunning, r.find_player, 'foo')
     self.assertEquals([], r.players_running)
Esempio n. 7
0
 def test_find_player_requested_not_running(self):
     r = mprisremote.MPRISRemote()
     self.assertRaises(mprisremote.RequestedPlayerNotRunning, r.find_player,
                       'bar')
     self.assertEquals(['org.mpris.foo'], r.players_running)
Esempio n. 8
0
 def test_find_player_success(self):
     r = mprisremote.MPRISRemote()
     r.find_player('foo')
     self.assertEquals(['org.mpris.foo'], r.players_running)
Esempio n. 9
0
 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()))
Esempio n. 10
0
 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()))
Esempio n. 11
0
 def callCommand(self, command, *args):
     dbus.start_mocking('foo')
     r = mprisremote.MPRISRemote()
     r.find_player('foo')
     getattr(r, command)(*args)