Пример #1
0
    def setup_data(self):
        self.manual_feed = testobjects.make_manual_feed()
        self.feed_with_downloads = testobjects.make_feed()
        self.feed_without_downloads = testobjects.make_feed()
        self.audio_items = []
        self.video_items = []
        self.undownloaded_items = []
        for i in xrange(10):
            self.audio_items.append(
                testobjects.make_file_item(self.feed_with_downloads,
                                           u'audio-item-%s' % i,
                                           ext='.mp3'))
            self.video_items.append(
                testobjects.make_file_item(self.manual_feed,
                                           u'video-item-%s' % i,
                                           ext='.avi'))
            self.undownloaded_items.append(
                testobjects.make_item(self.feed_without_downloads,
                                      u'feed-item-%s' % i))

        self.audio_playlist = models.SavedPlaylist(
            u'My music', [i.id for i in self.audio_items])
        # put some videos in the videos playlist.  These will be sent back by
        # the server, even if SHARE_VIDEO is not set
        self.video_playlist_items = self.video_items[:5]
        self.video_playlist = models.SavedPlaylist(
            u'My best videos', [i.id for i in self.video_playlist_items])
        app.db.finish_transaction()
        models.Item.change_tracker.reset()
Пример #2
0
 def test_playlist_changes(self):
     self.setup_sharing_manager_backend()
     initial_revision = self.backend.data_set.revision
     new_playlist = models.SavedPlaylist(u'My Playlist')
     self.audio_playlist.set_title(u'My Audio Files')
     self.video_playlist.remove()
     self.send_changes_from_trackers()
     self.assertNotEquals(self.backend.data_set.revision, initial_revision)
     self.check_daap_list(self.backend.get_playlists(), [
         self.feed_with_downloads, self.feed_without_downloads,
         self.audio_playlist, new_playlist
     ])
     self.check_daap_item_deleted(self.backend.get_playlists(),
                                  self.video_playlist)
     # test adding items
     second_revision = self.backend.data_set.revision
     for item in self.video_items:
         new_playlist.add_item(item)
     self.send_changes_from_trackers()
     self.assertNotEquals(self.backend.data_set.revision, second_revision)
     self.check_daap_list(self.backend.get_items(new_playlist.id),
                          self.video_items)
     # test removing items
     third_revision = self.backend.data_set.revision
     for item in self.video_items[4:]:
         new_playlist.remove_item(item)
     self.send_changes_from_trackers()
     self.assertNotEquals(self.backend.data_set.revision, third_revision)
     self.check_daap_list(self.backend.get_items(new_playlist.id),
                          self.video_items[:4])
Пример #3
0
 def setup_playlist(self):
     self.manual_feed = testobjects.make_manual_feed()
     items = testobjects.add_items_to_feed(self.manual_feed,
                                           10,
                                           file_items=True,
                                           prefix='playlist-')
     self.playlist = models.SavedPlaylist(u'playlist',
                                          [i.id for i in items])
     self.playlist_items = items
Пример #4
0
 def test_playlist_conditions(self):
     # change the query to something that involves playlist columns
     playlist = models.SavedPlaylist(u'My playlist')
     for item in self.tracked_items:
         playlist.add_item(item)
     app.db.finish_transaction()
     query = itemtrack.ItemTrackerQuery()
     query.add_condition('playlist_item_map.playlist_id', '=', playlist.id)
     self.tracker.change_query(query)
     self.check_one_signal('list-changed')
     self.check_tracker_items(self.tracked_items)
     # add items to the playlist
     new_items = self.other_items1[:4]
     for item in new_items:
         playlist.add_item(item)
     self.check_list_change_after_message()
     self.check_tracker_items(self.tracked_items + new_items)
     # remove items from the playlist
     removed_items = self.tracked_items[:4]
     for item in removed_items:
         playlist.remove_item(item)
     self.check_list_change_after_message()
     self.check_tracker_items(self.tracked_items[4:] + new_items)