Пример #1
0
 def test_track_to_mpd_format_for_nonempty_track(self):
     result = translator.track_to_mpd_format(CpTrack(122, self.track),
                                             position=9)
     self.assertIn(('file', 'a uri'), result)
     self.assertIn(('Time', 137), result)
     self.assertIn(('Artist', 'an artist'), result)
     self.assertIn(('Title', 'a name'), result)
     self.assertIn(('Album', 'an album'), result)
     self.assertIn(('AlbumArtist', 'an other artist'), result)
     self.assertIn(('Track', '7/13'), result)
     self.assertIn(('Date', datetime.date(1977, 1, 1)), result)
     self.assertIn(('Pos', 9), result)
     self.assertIn(('Id', 122), result)
     self.assertEqual(len(result), 10)
Пример #2
0
    def add(self, track, at_position=None, increase_version=True):
        """
        Add the track to the end of, or at the given position in the current
        playlist.

        :param track: track to add
        :type track: :class:`mopidy.models.Track`
        :param at_position: position in current playlist to add track
        :type at_position: int or :class:`None`
        :rtype: two-tuple of (CPID integer, :class:`mopidy.models.Track`) that
            was added to the current playlist playlist
        """
        assert at_position <= len(self._cp_tracks), \
            u'at_position can not be greater than playlist length'
        cp_track = CpTrack(self.cp_id, track)
        if at_position is not None:
            self._cp_tracks.insert(at_position, cp_track)
        else:
            self._cp_tracks.append(cp_track)
        if increase_version:
            self.version += 1
        self.cp_id += 1
        return cp_track
Пример #3
0
 def test_index_raises_value_error_if_item_not_found(self):
     test = lambda: self.controller.index(CpTrack(0, Track()))
     self.assertRaises(ValueError, test)
Пример #4
0
 def setUp(self):
     self.cpid = 123
     self.track = Track()
     self.cp_track = CpTrack(self.cpid, self.track)
Пример #5
0
 def test_track_to_mpd_format_with_position_and_cpid(self):
     result = translator.track_to_mpd_format(CpTrack(2, Track()),
                                             position=1)
     self.assertIn(('Pos', 1), result)
     self.assertIn(('Id', 2), result)
Пример #6
0
 def test_track_to_mpd_format_with_cpid(self):
     result = translator.track_to_mpd_format(CpTrack(1, Track()))
     self.assertNotIn(('Id', 1), result)