当前位置: 首页>>代码示例>>Python>>正文


Python playlist.SavedPlaylist类代码示例

本文整理汇总了Python中miro.playlist.SavedPlaylist的典型用法代码示例。如果您正苦于以下问题:Python SavedPlaylist类的具体用法?Python SavedPlaylist怎么用?Python SavedPlaylist使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SavedPlaylist类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

 def setUp(self):
     TrackerTest.setUp(self)
     self.playlist1 = SavedPlaylist(u'Playlist 1')
     self.playlist2 = SavedPlaylist(u'Playlist 2')
     self.folder = PlaylistFolder(u'Playlist Folder')
     self.runUrgentCalls()
     messages.TrackPlaylists().send_to_backend()
     self.runUrgentCalls()
开发者ID:ShriramK,项目名称:miro,代码行数:8,代码来源:messagetest.py

示例2: test_callbacks

 def test_callbacks(self):
     initialList = [self.i1, self.i2, self.i3]
     playlist = SavedPlaylist(u"rocketboom", [i.id for i in initialList])
     tracker = Item.playlist_view(playlist.id).make_tracker()
     tracker.connect('added', self.add_callback)
     tracker.connect('removed', self.remove_callback)
     playlist.add_item(self.i4)
     self.check_callbacks([self.i4], [])
     playlist.remove_item(self.i3)
     self.check_callbacks([self.i4], [self.i3])
开发者ID:cool-RR,项目名称:Miro,代码行数:10,代码来源:playlisttest.py

示例3: setUp

 def setUp(self):
     PlaylistTestBase.setUp(self)
     self.playlistTabOrder = tabs.TabOrder(u"playlist")
     self.p1 = SavedPlaylist(u"rocketboom", [self.i1.id, self.i3.id])
     self.p2 = SavedPlaylist(u"telemusicvision", [self.i4.id, self.i3.id])
     self.p3 = SavedPlaylist(u"digg", [self.i1.id, self.i2.id, self.i3.id, self.i4.id])
     self.folder = PlaylistFolder(u"My Best Vids")
     self.p1.set_folder(self.folder)
     self.p2.set_folder(self.folder)
     self.p3.set_folder(self.folder)
开发者ID:ktan2020,项目名称:miro,代码行数:10,代码来源:playlisttest.py

示例4: test_reduce_number_of_messages

 def test_reduce_number_of_messages(self):
     p1 = SavedPlaylist(u'Playlist')
     p1.remove()
     p2 = SavedPlaylist(u'Playlist 2')
     p2.set_title(u'New Title')
     self.runUrgentCalls()
     # We don't need to see that p1 was added because it got
     # removed immediately after.  We don't need to see that p2 was
     # changed because it will have the updated info in added.
     self.check_message_count(2)
     self.check_changed_message(1, added=[p2])
开发者ID:ShriramK,项目名称:miro,代码行数:11,代码来源:messagetest.py

示例5: test_initial_list

 def test_initial_list(self):
     initialList = [self.i1, self.i2, self.i3]
     playlist = SavedPlaylist(u"rocketboom", [i.id for i in initialList])
     self.assertEquals(playlist.get_title(), u'rocketboom')
     self.check_list(playlist, initialList)
开发者ID:cool-RR,项目名称:Miro,代码行数:5,代码来源:playlisttest.py

示例6: test_basic_operations

 def test_basic_operations(self):
     playlist = SavedPlaylist(u"rocketboom")
     self.assertEquals(playlist.get_title(), u'rocketboom')
     self.check_list(playlist, [])
     playlist.add_item(self.i4)
     playlist.add_item(self.i1)
     playlist.add_item(self.i3)
     playlist.add_item(self.i2)
     self.check_list(playlist, [self.i4, self.i1, self.i3, self.i2])
     playlist.add_item(self.i2)
     self.check_list(playlist, [self.i4, self.i1, self.i3, self.i2])
     self.assert_(self.i1.keep)
     self.assert_(self.i2.keep)
     self.assert_(self.i3.keep)
     self.assert_(self.i4.keep)
     playlist.remove_item(self.i2)
     self.check_list(playlist, [self.i4, self.i1, self.i3])
     playlist.reorder([self.i3.id, self.i4.id, self.i1.id])
     self.check_list(playlist, [self.i3, self.i4, self.i1])
     playlist.remove_item(self.i3)
     self.check_list(playlist, [self.i4, self.i1])
开发者ID:cool-RR,项目名称:Miro,代码行数:21,代码来源:playlisttest.py

示例7: test_live_storage_converts

    def test_live_storage_converts(self):
        # FIXME - this test fails on Windows.  I'm pretty sure we need
        # a Windows-specific predbupgrade88 because the databases are
        # platform specific.
        if self.on_windows():
            self.assert_(False, "test_live_storage_converts fails on windows")
        # run upgrade 88
        old_db_path = resources.path("testdata/olddatabase.predbupgrade88")
        shutil.copyfile(old_db_path, self.tmp_path)
        self.reload_database(self.tmp_path)
        app.db.upgrade_database()
        # figure out which maps were created
        folder_maps = set()
        playlist_maps = set()
        for map in PlaylistFolderItemMap.make_view():
            folder_maps.add((map.playlist_id, map.item_id, map.position,
                map.count))
            self.assert_(map.id is not None)

        for map in PlaylistItemMap.make_view():
            playlist_maps.add((map.playlist_id, map.item_id, map.position))
            self.assert_(map.id is not None)

        playlist1 = SavedPlaylist.make_view("title='playlist1'").get_singleton()
        playlist2 = SavedPlaylist.make_view("title='playlist2'").get_singleton()
        folder = PlaylistFolder.make_view().get_singleton()

        # Double check that we have the right item ids
        self.assertEquals(Item.get_by_id(242).get_title(),
                u"Berliner Brats n' Kraut")
        self.assertEquals(Item.get_by_id(240).get_title(),
                u"White Bean & Basil Bruschetta")
        self.assertEquals(Item.get_by_id(79).get_title(), u"Meet the GIMP!")
        self.assertEquals(Item.get_by_id(69).get_title(),
                u"Delicious TV Vegetarian (video)")
        # check that folder contains playlist 1
        self.assertEquals(playlist1.folder_id, folder.id)
        self.assertEquals(playlist2.folder_id, folder.id)
        # Check that the playlist maps follow the following structure:
        #
        # folder1:
        #    - Berliner Brats n' Kraut (id: 242)
        #    - White Bean & Basil Bruschetta (id: 240)
        #    - Meet the GIMP! (id: 79)
        #    - Delicious TV Vegetarian (video) (id: 69)
        # playlist1
        #    - White Bean & Basil Bruschetta (id: 240)
        #    - Berliner Brats n' Kraut (id: 242)
        # playlist2
        #    - Meet the GIMP! (id: 79)
        #    - Delicious TV Vegetarian (video) (id: 69)
        #    - White Bean & Basil Bruschetta (id: 240)
        self.assertEquals(folder_maps, set([
            (folder.id, 242, 0, 1),
            (folder.id, 240, 1, 2),
            (folder.id, 79, 2, 1),
            (folder.id, 69, 3, 1),
        ]))
        self.assertEquals(playlist_maps, set([
            (playlist1.id, 240, 0),
            (playlist1.id, 242, 1),
            (playlist2.id, 79, 0),
            (playlist2.id, 69, 1),
            (playlist2.id, 240, 2),
        ]))
开发者ID:cool-RR,项目名称:Miro,代码行数:65,代码来源:playlisttest.py

示例8: test_remove_folder_removes_playlist

 def test_remove_folder_removes_playlist(self):
     self.folder.remove()
     self.assertEquals(SavedPlaylist.make_view().count(), 0)
开发者ID:cool-RR,项目名称:Miro,代码行数:3,代码来源:playlisttest.py

示例9: PlaylistFolderTestCase

class PlaylistFolderTestCase(PlaylistTestBase):
    def setUp(self):
        PlaylistTestBase.setUp(self)
        self.playlistTabOrder = tabs.TabOrder(u'playlist')
        self.p1 = SavedPlaylist(u"rocketboom", [self.i1.id, self.i3.id])
        self.p2 = SavedPlaylist(u"telemusicvision", [self.i4.id, self.i3.id])
        self.p3 = SavedPlaylist(u"digg", [self.i1.id, self.i2.id,
                                          self.i3.id, self.i4.id])
        self.folder = PlaylistFolder(u"My Best Vids")
        self.p1.set_folder(self.folder)
        self.p2.set_folder(self.folder)
        self.p3.set_folder(self.folder)

    def check_list(self, correct_order):
        correct_ids = [item.id for item in correct_order]
        actual_ids = list(i.id for i in
                Item.playlist_folder_view(self.folder.id))
        self.assertEquals(actual_ids, correct_ids)

    def test_add_playlists(self):
        self.check_list([self.i1, self.i3, self.i4, self.i2])

    def test_change_folder(self):
        self.p3.set_folder(None)
        self.check_list([self.i1, self.i3, self.i4])
        self.p2.set_folder(None)
        self.check_list([self.i1, self.i3])
        self.p1.set_folder(None)
        self.check_list([])

    def test_remove_playlist(self):
        self.p3.remove()
        self.check_list([self.i1, self.i3, self.i4])
        self.p2.remove()
        self.check_list([self.i1, self.i3])
        self.p1.remove()
        self.check_list([])

    def test_remove_items_from_playlist(self):
        self.p3.remove_item(self.i2)
        self.check_list([self.i1, self.i3, self.i4])
        self.p3.remove_item(self.i3)
        # i3 is still in other children of self.folder, so it
        # shouldn't be removed
        self.check_list([self.i1, self.i3, self.i4])

    def test_order_independent(self):
        self.p3.reorder([self.i4.id, self.i2.id, self.i3.id, self.i1.id])
        self.check_list([self.i1, self.i3, self.i4, self.i2])
        self.folder.reorder([self.i4.id, self.i3.id, self.i2.id, self.i1.id])
        self.check_list([self.i4, self.i3, self.i2, self.i1])

    def test_remove_folder_removes_playlist(self):
        self.folder.remove()
        self.assertEquals(SavedPlaylist.make_view().count(), 0)
开发者ID:cool-RR,项目名称:Miro,代码行数:55,代码来源:playlisttest.py

示例10: PlaylistItemTrackTest

class PlaylistItemTrackTest(TrackerTest):
    def setUp(self):
        TrackerTest.setUp(self)
        self.items = []
        self.feed = Feed(u'dtv:manualFeed')
        self.playlist = SavedPlaylist(u'test playlist')
        self.make_item(u'http://example.com/')
        self.make_item(u'http://example.com/2')
        self.runUrgentCalls()
        messages.TrackItems('playlist', self.playlist.id).send_to_backend()
        self.runUrgentCalls()

    def make_item(self, url):
        entry = _build_entry(url, 'video/x-unknown')
        item_ = Item(FeedParserValues(entry), feed_id=self.feed.id)
        self.items.append(item_)
        self.playlist.add_item(item_)

    def checkDownloadInfo(self, info, item):
        downloader = item.downloader
        self.assertEquals(info.current_size, downloader.get_current_size())
        self.assertEquals(info.rate, downloader.get_rate())
        self.assertEquals(info.state, downloader.get_state())

    def check_info(self, itemInfo, item):
        self.assertEquals(itemInfo.name, item.get_title())
        self.assertEquals(itemInfo.description, item.get_description())
        self.assertEquals(itemInfo.release_date, item.get_release_date())
        self.assertEquals(itemInfo.size, item.get_size())
        self.assertEquals(itemInfo.permalink, item.get_link())
        self.assertEquals(itemInfo.id, item.id)
        self.assertEquals(itemInfo.expiration_date, item.get_expiration_time())
        self.assertEquals(itemInfo.thumbnail, item.get_thumbnail())
        if item.downloader:
            self.checkDownloadInfo(itemInfo.download_info)
        else:
            self.assertEquals(itemInfo.download_info, None)

    def check_changed_message_type(self, message):
        self.assertEquals(type(message), messages.ItemsChanged)
        self.assertEquals(message.type, 'playlist')

    def test_initial_list(self):
        self.assertEquals(len(self.test_handler.messages), 1)
        message = self.test_handler.messages[0]
        self.assert_(isinstance(message, messages.ItemList))
        self.assertEquals(message.type, 'playlist')
        self.assertEquals(message.id, self.playlist.id)

        self.assertEquals(len(message.items), len(self.items))
        message.items.sort(key=lambda i: i.id)
        self.check_info_list(message.items, self.items)

    def test_update(self):
        self.items[0].entry_title = u'new name'
        self.items[0].signal_change()
        self.runUrgentCalls()
        self.assertEquals(len(self.test_handler.messages), 2)
        self.check_changed_message(1, changed=[self.items[0]])

    def test_add(self):
        self.make_item(u'http://example.com/3')
        self.make_item(u'http://example.com/4')
        self.make_item(u'http://example.com/5')
        self.runUrgentCalls()
        self.assertEquals(len(self.test_handler.messages), 2)
        self.check_changed_message(1, added=self.items[2:])

    def test_remove(self):
        self.items[1].remove()
        self.runUrgentCalls()
        self.assertEquals(len(self.test_handler.messages), 2)
        self.check_changed_message(1, removed=[self.items[1]])

    def test_stop(self):
        messages.StopTrackingItems(
            'playlist', self.playlist.id).send_to_backend()
        self.runUrgentCalls()
        self.items[0].entry_title = u'new name'
        self.items[0].signal_change()
        self.items[1].remove()
        self.make_item(u'http://example.com/4')
        self.runUrgentCalls()
        self.assertEquals(len(self.test_handler.messages), 1)
开发者ID:ShriramK,项目名称:miro,代码行数:84,代码来源:messagetest.py

示例11: PlaylistTrackTest

class PlaylistTrackTest(TrackerTest):
    def setUp(self):
        TrackerTest.setUp(self)
        self.playlist1 = SavedPlaylist(u'Playlist 1')
        self.playlist2 = SavedPlaylist(u'Playlist 2')
        self.folder = PlaylistFolder(u'Playlist Folder')
        self.runUrgentCalls()
        messages.TrackPlaylists().send_to_backend()
        self.runUrgentCalls()

    def test_initial_list(self):
        self.assertEquals(len(self.test_handler.messages), 1)
        message = self.test_handler.messages[0]
        self.assert_(isinstance(message, messages.TabList))
        self.assertEquals(message.type, 'playlist')
        self.check_info_list(message.toplevels,
                             [self.playlist1, self.playlist2, self.folder])
        self.check_info_list(message.folder_children[self.folder.id], [])
        self.assertEquals(len(message.folder_children), 1)

    def check_info(self, playlistInfo, playlist):
        self.assertEquals(playlistInfo.name, playlist.get_title())
        self.assertEquals(playlistInfo.id, playlist.id)
        self.assertEquals(playlistInfo.is_folder,
                isinstance(playlist, PlaylistFolder))

    def check_changed_message_type(self, message):
        self.assertEquals(type(message), messages.TabsChanged)
        self.assertEquals(message.type, 'playlist')

    def test_added(self):
        p = SavedPlaylist(u'http://example.com/3')
        self.runUrgentCalls()
        self.check_message_count(2)
        self.check_changed_message(1, added=[p])

    def test_added_order(self):
        p1 = SavedPlaylist(u'Playlist 2')
        p2 = SavedPlaylist(u'Playlist 3')
        p3 = SavedPlaylist(u'Playlist 4')
        p4 = SavedPlaylist(u'Playlist 5')
        p5 = SavedPlaylist(u'Playlist 6')
        self.runUrgentCalls()
        # We want the PlaylistAdded messages to come in the same order
        # the feeds were added.
        self.check_message_count(2)
        self.check_changed_message(1, added=[p1, p2, p3, p4, p5])

    def test_removed(self):
        self.playlist2.remove()
        self.runUrgentCalls()
        self.check_message_count(2)
        self.check_changed_message(1, removed=[self.playlist2])

    def test_change(self):
        self.playlist1.set_title(u"Booya")
        self.runUrgentCalls()
        self.check_message_count(2)
        self.check_changed_message(1, changed=[self.playlist1])

    def test_reduce_number_of_messages(self):
        p1 = SavedPlaylist(u'Playlist')
        p1.remove()
        p2 = SavedPlaylist(u'Playlist 2')
        p2.set_title(u'New Title')
        self.runUrgentCalls()
        # We don't need to see that p1 was added because it got
        # removed immediately after.  We don't need to see that p2 was
        # changed because it will have the updated info in added.
        self.check_message_count(2)
        self.check_changed_message(1, added=[p2])

    def test_stop(self):
        self.check_message_count(1)
        messages.StopTrackingPlaylists().send_to_backend()
        self.runUrgentCalls()
        self.playlist1.set_title(u"Booya")
        Feed(u'http://example.com/3')
        self.playlist2.remove()
        self.check_message_count(1)
开发者ID:ShriramK,项目名称:miro,代码行数:80,代码来源:messagetest.py


注:本文中的miro.playlist.SavedPlaylist类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。