Ejemplo n.º 1
0
 def test_simple_overflow(self):
     self.assertEqual(Item.make_view().count(), 2)
     self.parse_new_feed()
     self.assertEqual(Item.make_view().count(), 4)
     self.parse_new_feed()
     self.assertEqual(Item.make_view().count(), 4)
     self.check_guids(3, 4, 5, 6)
Ejemplo n.º 2
0
 def setUp(self):
     MiroTestCase.setUp(self)
     self.feed = Feed(u'http://example.com/1')
     self.item1 = Item(fp_values_for_url(u'http://example.com/1/item1'),
                       feed_id=self.feed.id)
     self.item2 = Item(fp_values_for_url(u'http://example.com/1/item2'),
                       feed_id=self.feed.id)
Ejemplo n.º 3
0
 def test_watched_time_reset(self):
     feed = Feed(u'http://example.com/1')
     item = Item(fp_values_for_url(u'http://example.com/1/item1'),
             feed_id=feed.id)
     item.watchedTime = datetime.now()
     item.expire()
     self.assertEquals(item.watchedTime, None)
Ejemplo n.º 4
0
 def test_watched_time_reset(self):
     feed = Feed(u'http://example.com/1')
     item = Item(fp_values_for_url(u'http://example.com/1/item1'),
                 feed_id=feed.id)
     item.watched_time = datetime.now()
     item.expire()
     self.assertEquals(item.watched_time, None)
Ejemplo n.º 5
0
 def setUp(self):
     MiroTestCase.setUp(self)
     self.feed = Feed(u'http://example.com/1')
     self.item1 = Item(fp_values_for_url(u'http://example.com/1/item1'),
             feed_id=self.feed.id)
     self.item2 = Item(fp_values_for_url(u'http://example.com/1/item2'),
             feed_id=self.feed.id)
Ejemplo n.º 6
0
 def test_simple_overflow(self):
     self.assertEqual(Item.make_view().count(), 2)
     self.parse_new_feed()
     self.assertEqual(Item.make_view().count(), 4)
     self.parse_new_feed()
     self.assertEqual(Item.make_view().count(), 4)
     self.check_guids(3, 4, 5, 6)
Ejemplo n.º 7
0
 def test_set_rating(self):
     feed = Feed(u'http://example.com/1')
     item = Item(fp_values_for_url(u'http://example.com/1/item1'),
             feed_id=feed.id)
     item.set_rating(5)
     self.assertEquals(item.rating, 5)
     item.set_rating(3)
     self.assertEquals(item.rating, 3)
Ejemplo n.º 8
0
 def test_strips_tags(self):
     # Only feeds created with a title get the tags stripped in the title.
     # When using item.set_title() no tags are stripped.
     f1 = Feed(u'http://example.com/1')
     item = Item(fp_values_for_url(u'http://example.com/1/item1', {'title':u"<em>miro</em>"}), feed_id=f1.id)
     self.assertEquals(item.matches_search('miro'), True)
     self.assertEquals(item.matches_search('<em'), False)
     self.assertEquals(item.matches_search('em>'), False)
     self.assertEquals(item.matches_search('<em>miro</miro'), False)
Ejemplo n.º 9
0
 def test_run(self):
     my_feed = self.make_feed()
     items = list(Item.make_view())
     self.assertEqual(len(items), 4)
     # make sure that re-updating doesn't re-create the items
     my_feed.update()
     items = list(Item.make_view())
     self.assertEqual(len(items), 4)
     my_feed.remove()
Ejemplo n.º 10
0
 def test_run(self):
     my_feed = self.make_feed()
     items = list(Item.make_view())
     self.assertEqual(len(items), 4)
     # make sure that re-updating doesn't re-create the items
     my_feed.update()
     items = list(Item.make_view())
     self.assertEqual(len(items), 4)
     my_feed.remove()
Ejemplo n.º 11
0
class ItemSearchTest(MiroTestCase):
    def setUp(self):
        MiroTestCase.setUp(self)
        self.feed = Feed(u'http://example.com/1')
        self.item1 = Item(fp_values_for_url(u'http://example.com/1/item1'),
                feed_id=self.feed.id)
        self.item2 = Item(fp_values_for_url(u'http://example.com/1/item2'),
                feed_id=self.feed.id)

    def test_matches_search(self):
        self.item1.title = u"miro is cool"
        self.item1.signal_change()
        self.assertEquals(self.item1.matches_search('miro'), True)
        self.assertEquals(self.item1.matches_search('iro'), True)
        self.assertEquals(self.item1.matches_search('c'), True)
        self.assertEquals(self.item1.matches_search('miro is'), True)
        self.assertEquals(self.item1.matches_search('ool m'), True)
        self.assertEquals(self.item1.matches_search('miros'), False)
        self.assertEquals(self.item1.matches_search('iscool'), False)
        self.assertEquals(self.item1.matches_search('cool -miro'), False)

    def test_strips_tags(self):
        # Only feeds created with a title get the tags stripped in the title.
        # When using item.set_title() no tags are stripped.
        f1 = Feed(u'http://example.com/1')
        item = Item(fp_values_for_url(u'http://example.com/1/item1', {'title':u"<em>miro</em>"}), feed_id=f1.id)
        self.assertEquals(item.matches_search('miro'), True)
        self.assertEquals(item.matches_search('<em'), False)
        self.assertEquals(item.matches_search('em>'), False)
        self.assertEquals(item.matches_search('<em>miro</miro'), False)
Ejemplo n.º 12
0
class ItemSearchTest(MiroTestCase):
    def setUp(self):
        MiroTestCase.setUp(self)
        self.feed = Feed(u'http://example.com/1')
        self.item1 = Item(fp_values_for_url(u'http://example.com/1/item1'),
                          feed_id=self.feed.id)
        self.item2 = Item(fp_values_for_url(u'http://example.com/1/item2'),
                          feed_id=self.feed.id)

    def test_matches_search(self):
        self.item1.title = u"miro is cool"
        self.item1.signal_change()
        self.assertEquals(self.item1.matches_search('miro'), True)
        self.assertEquals(self.item1.matches_search('iro'), True)
        self.assertEquals(self.item1.matches_search('c'), True)
        self.assertEquals(self.item1.matches_search('miro is'), True)
        self.assertEquals(self.item1.matches_search('ool m'), True)
        self.assertEquals(self.item1.matches_search('miros'), False)
        self.assertEquals(self.item1.matches_search('iscool'), False)
        self.assertEquals(self.item1.matches_search('cool -miro'), False)

    def test_strips_tags(self):
        # Only feeds created with a title get the tags stripped in the title.
        # When using item.set_title() no tags are stripped.
        f1 = Feed(u'http://example.com/1')
        item = Item(fp_values_for_url(u'http://example.com/1/item1',
                                      {'title': u"<em>miro</em>"}),
                    feed_id=f1.id)
        self.assertEquals(item.matches_search('miro'), True)
        self.assertEquals(item.matches_search('<em'), False)
        self.assertEquals(item.matches_search('em>'), False)
        self.assertEquals(item.matches_search('<em>miro</miro'), False)
Ejemplo n.º 13
0
class ItemSearchTest(MiroTestCase):
    def setUp(self):
        MiroTestCase.setUp(self)
        self.feed = Feed(u"http://example.com/1")
        self.item1 = Item(fp_values_for_url(u"http://example.com/1/item1"), feed_id=self.feed.id)
        self.item2 = Item(fp_values_for_url(u"http://example.com/1/item2"), feed_id=self.feed.id)

    def test_matches_search(self):
        self.item1.set_title(u"miro is cool")
        self.assertEquals(self.item1.matches_search("miro"), True)
        self.assertEquals(self.item1.matches_search("iro"), True)
        self.assertEquals(self.item1.matches_search("c"), True)
        self.assertEquals(self.item1.matches_search("miro is"), True)
        self.assertEquals(self.item1.matches_search("ool m"), True)
        self.assertEquals(self.item1.matches_search("miros"), False)
        self.assertEquals(self.item1.matches_search("iscool"), False)
        self.assertEquals(self.item1.matches_search("cool -miro"), False)

    def test_strips_tags(self):
        # Only feeds created with a title get the tags stripped in the title.
        # When using item.set_title() no tags are stripped.
        f1 = Feed(u"http://example.com/1")
        item = Item(fp_values_for_url(u"http://example.com/1/item1", {"title": u"<em>miro</em>"}), feed_id=f1.id)
        self.assertEquals(item.matches_search("miro"), True)
        self.assertEquals(item.matches_search("<em"), False)
        self.assertEquals(item.matches_search("em>"), False)
        self.assertEquals(item.matches_search("<em>miro</miro"), False)
Ejemplo n.º 14
0
 def test_strips_tags(self):
     # Only feeds created with a title get the tags stripped in the title.
     # When using item.set_title() no tags are stripped.
     f1 = Feed(u'http://example.com/1')
     item = Item(fp_values_for_url(u'http://example.com/1/item1',
                                   {'title': u"<em>miro</em>"}),
                 feed_id=f1.id)
     self.assertEquals(item.matches_search('miro'), True)
     self.assertEquals(item.matches_search('<em'), False)
     self.assertEquals(item.matches_search('em>'), False)
     self.assertEquals(item.matches_search('<em>miro</miro'), False)
Ejemplo n.º 15
0
 def setUp(self):
     EventLoopTest.setUp(self)
     self.feed = Feed(u"http://feed.uk")
     self.i1 = Item(FeedParserValues({'title': u'item1'}),
                    feed_id=self.feed.id)
     self.i2 = Item(FeedParserValues({'title': u'item2'}),
                    feed_id=self.feed.id)
     self.i3 = Item(FeedParserValues({'title': u'item3'}),
                    feed_id=self.feed.id)
     self.i4 = Item(FeedParserValues({'title': u'item4'}),
                    feed_id=self.feed.id)
Ejemplo n.º 16
0
    def test_expired_view_3(self):
        f3 = Feed(u"http://example.com/3")

        i5 = Item(fp_values_for_url(u"http://example.com/3/item1"), feed_id=f3.id)
        i6 = Item(fp_values_for_url(u"http://example.com/3/item2"), feed_id=f3.id)

        f3.set_expiration(u"feed", 24)
        i5.watchedTime = datetime.now() - timedelta(days=3)
        i6.watchedTime = datetime.now() - timedelta(hours=12)

        for obj in (f3, i5, i6):
            obj.signal_change()

        self.assertEquals(list(f3.expiring_items()), [i5])
Ejemplo n.º 17
0
    def test_expired_view_1(self):
        f1 = Feed(u'http://example.com/1')

        i1 = Item(fp_values_for_url(u'http://example.com/1/item1'),
                  feed_id=f1.id)
        i2 = Item(fp_values_for_url(u'http://example.com/1/item2'),
                  feed_id=f1.id)

        f1.set_expiration(u'never', 0)
        i1.watched_time = i2.watched_time = datetime.now()

        for obj in (f1, i1, i2):
            obj.signal_change()

        self.assertEquals(list(f1.expiring_items()), [])
Ejemplo n.º 18
0
    def test_remove_before_downloader_referenced(self):
        # when items are restored from the DB, the downloader
        # attribute is loaded lazily.  Make sure that if we remove the
        # item, the downloader is still removed.
        feed = Feed(u"http://example.com/1")
        item = Item(fp_values_for_url(u"http://example.com/1/item1"), feed_id=feed.id)
        item.set_downloader(RemoteDownloader(u"http://example.com/1/item1/movie.mpeg", item))
        downloader = item.downloader

        feed = self.reload_object(feed)
        downloader = self.reload_object(downloader)
        item = self.reload_object(item)

        item.remove()
        self.assert_(not downloader.id_exists())
Ejemplo n.º 19
0
    def test_expired_view_2(self):
        f2 = Feed(u"http://example.com/2")

        i3 = Item(fp_values_for_url(u"http://example.com/2/item1"), feed_id=f2.id)
        i4 = Item(fp_values_for_url(u"http://example.com/2/item2"), feed_id=f2.id)

        f2.set_expiration(u"system", 0)
        # system default is 6 days as set in setUp, so i3 should expire,
        # but i4 should not.
        i3.watchedTime = datetime.now() - timedelta(days=12)
        i4.watchedTime = datetime.now() - timedelta(days=3)

        for obj in (f2, i3, i4):
            obj.signal_change()

        self.assertEquals(list(f2.expiring_items()), [i3])
Ejemplo n.º 20
0
    def test_run(self):
        dialogs.delegate = AcceptScrapeTestDelegate()
        my_feed = self.make_feed()

        # the feed has no enclosures, but we now insert enclosures into it.
        # thus it should not cause a dialog to pop up and ask the user if they
        # want to scrape.
        self.assertEqual(dialogs.delegate.calls, 0)
        # the Feed, plus the 1 item that is a video
        items = list(Item.make_view())
        self.assertEqual(len(items), 1)

        # make sure that re-updating doesn't re-create the items
        my_feed.update()
        items = list(Item.make_view())
        self.assertEqual(len(items), 1)
        my_feed.remove()
Ejemplo n.º 21
0
 def test_overflow_with_downloads(self):
     items = list(Item.make_view())
     items[0]._downloader = FakeDownloader()
     items[1]._downloader = FakeDownloader()
     self.assertEqual(len(items), 2)
     self.parse_new_feed()
     self.parse_new_feed()
     self.check_guids(1, 2, 5, 6)
Ejemplo n.º 22
0
    def test_run(self):
        dialogs.delegate = AcceptScrapeTestDelegate()
        my_feed = self.make_feed()

        # the feed has no enclosures, but we now insert enclosures into it.
        # thus it should not cause a dialog to pop up and ask the user if they
        # want to scrape.
        self.assertEqual(dialogs.delegate.calls, 0)
        # the Feed, plus the 1 item that is a video
        items = list(Item.make_view())
        self.assertEqual(len(items), 1)

        # make sure that re-updating doesn't re-create the items
        my_feed.update()
        items = list(Item.make_view())
        self.assertEqual(len(items), 1)
        my_feed.remove()
Ejemplo n.º 23
0
 def test_overflow_with_downloads(self):
     items = list(Item.make_view())
     items[0]._downloader = FakeDownloader()
     items[1]._downloader = FakeDownloader()
     self.assertEqual(len(items), 2)
     self.parse_new_feed()
     self.parse_new_feed()
     self.check_guids(1, 2, 5, 6)
Ejemplo n.º 24
0
 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])
Ejemplo n.º 25
0
 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])
Ejemplo n.º 26
0
 def test_overflow_with_global_max_old_items(self):
     app.config.set(prefs.TRUNCATE_CHANNEL_AFTER_X_ITEMS, 1000) # don't bother
     self.assertEqual(Item.make_view().count(), 2)
     self.parse_new_feed()
     self.assertEquals(Item.make_view().count(), 4)
     self.parse_new_feed()
     app.config.set(prefs.MAX_OLD_ITEMS_DEFAULT, 4)
     self.feed.actualFeed.clean_old_items()
     while self.feed.actualFeed.updating:
         self.processThreads()
         self.process_idles()
         sleep(0.1)
     self.assertEquals(Item.make_view().count(), 6)
     app.config.set(prefs.MAX_OLD_ITEMS_DEFAULT, 2)
     self.feed.actualFeed.clean_old_items()
     while self.feed.actualFeed.updating:
         self.processThreads()
         self.process_idles()
         sleep(0.1)
     self.assertEquals(Item.make_view().count(), 4)
     self.check_guids(3, 4, 5, 6)
Ejemplo n.º 27
0
 def test_overflow_with_global_max_old_items(self):
     app.config.set(prefs.TRUNCATE_CHANNEL_AFTER_X_ITEMS,
                    1000)  # don't bother
     self.assertEqual(Item.make_view().count(), 2)
     self.parse_new_feed()
     self.assertEquals(Item.make_view().count(), 4)
     self.parse_new_feed()
     app.config.set(prefs.MAX_OLD_ITEMS_DEFAULT, 4)
     self.feed.actualFeed.clean_old_items()
     while self.feed.actualFeed.updating:
         self.processThreads()
         self.process_idles()
         sleep(0.1)
     self.assertEquals(Item.make_view().count(), 6)
     app.config.set(prefs.MAX_OLD_ITEMS_DEFAULT, 2)
     self.feed.actualFeed.clean_old_items()
     while self.feed.actualFeed.updating:
         self.processThreads()
         self.process_idles()
         sleep(0.1)
     self.assertEquals(Item.make_view().count(), 4)
     self.check_guids(3, 4, 5, 6)
Ejemplo n.º 28
0
 def test_set_rating(self):
     feed = Feed(u'http://example.com/1')
     item = Item(fp_values_for_url(u'http://example.com/1/item1'),
                 feed_id=feed.id)
     item.set_rating(5)
     self.assertEquals(item.rating, 5)
     item.set_rating(3)
     self.assertEquals(item.rating, 3)
Ejemplo n.º 29
0
 def check_have_item_for_path(self):
     for path, item in self.added_items.items():
         self.assertEquals(Item.have_item_for_path(path), True)
         # case differences shouldn't matter
         self.assertEquals(Item.have_item_for_path(path.lower()), True)
         self.assertEquals(Item.have_item_for_path(path.upper()), True)
     for path in self.deleted_paths:
         self.assertEquals(Item.have_item_for_path(path), False)
         self.assertEquals(Item.have_item_for_path(path.upper()), False)
         self.assertEquals(Item.have_item_for_path(path.lower()), False)
Ejemplo n.º 30
0
 def check_have_item_for_path(self):
     for path, item in self.added_items.items():
         self.assertEquals(Item.have_item_for_path(path), True)
         # case differences shouldn't matter
         self.assertEquals(Item.have_item_for_path(path.lower()), True)
         self.assertEquals(Item.have_item_for_path(path.upper()), True)
     for path in self.deleted_paths:
         self.assertEquals(Item.have_item_for_path(path), False)
         self.assertEquals(Item.have_item_for_path(path.upper()), False)
         self.assertEquals(Item.have_item_for_path(path.lower()), False)
Ejemplo n.º 31
0
    def test_change_in_setup_restored(self):
        # Test Items changing themselve is setup_restored after we've loaded
        # the item info cache.

        self.clear_ddb_object_cache()
        # ensure that Item calls signal_change in setup_restored
        old_setup_restored = Item.setup_restored
        def new_setup_restored(self):
            old_setup_restored(self)
            self.title = u'new title2'
            self.signal_change()
        Item.setup_restored = new_setup_restored
        try:
            # Causes the items to be loaded from the db
            list(Item.feed_view(self.feed.id))
        finally:
            Item.setup_restored = old_setup_restored
        cached_info = self.get_info_from_item_info_cache(self.items[0].id)
        self.assertEquals(cached_info.name, 'new title2')
Ejemplo n.º 32
0
    def test_change_in_setup_restored(self):
        # Test Items changing themselve is setup_restored after we've loaded
        # the item info cache.

        self.clear_ddb_object_cache()
        # ensure that Item calls signal_change in setup_restored
        old_setup_restored = Item.setup_restored

        def new_setup_restored(self):
            old_setup_restored(self)
            self.title = u'new title2'
            self.signal_change()

        Item.setup_restored = new_setup_restored
        try:
            # Causes the items to be loaded from the db
            list(Item.feed_view(self.feed.id))
        finally:
            Item.setup_restored = old_setup_restored
        cached_info = self.get_info_from_item_info_cache(self.items[0].id)
        self.assertEquals(cached_info.name, 'new title2')
Ejemplo n.º 33
0
    def test_expired_view_3(self):
        f3 = Feed(u'http://example.com/3')

        i5 = Item(fp_values_for_url(u'http://example.com/3/item1'),
                  feed_id=f3.id)
        i6 = Item(fp_values_for_url(u'http://example.com/3/item2'),
                  feed_id=f3.id)

        f3.set_expiration(u'feed', 24)
        i5.watched_time = datetime.now() - timedelta(days=3)
        i6.watched_time = datetime.now() - timedelta(hours=12)

        for obj in (f3, i5, i6):
            obj.signal_change()

        self.assertEquals(list(f3.expiring_items()), [i5])
Ejemplo n.º 34
0
    def test_remove_before_downloader_referenced(self):
        # when items are restored from the DB, the downloader
        # attribute is loaded lazily.  Make sure that if we remove the
        # item, the downloader is still removed.
        feed = Feed(u'http://example.com/1')
        item = Item(fp_values_for_url(u'http://example.com/1/item1'),
                    feed_id=feed.id)
        item.set_downloader(
            RemoteDownloader(u'http://example.com/1/item1/movie.mpeg', item))
        downloader = item.downloader

        feed = self.reload_object(feed)
        downloader = self.reload_object(downloader)
        item = self.reload_object(item)

        item.remove()
        self.assert_(not downloader.id_exists())
Ejemplo n.º 35
0
    def test_expired_view_2(self):
        f2 = Feed(u'http://example.com/2')

        i3 = Item(fp_values_for_url(u'http://example.com/2/item1'),
                  feed_id=f2.id)
        i4 = Item(fp_values_for_url(u'http://example.com/2/item2'),
                  feed_id=f2.id)

        f2.set_expiration(u'system', 0)
        # system default is 6 days as set in setUp, so i3 should expire,
        # but i4 should not.
        i3.watched_time = datetime.now() - timedelta(days=12)
        i4.watched_time = datetime.now() - timedelta(days=3)

        for obj in (f2, i3, i4):
            obj.signal_change()

        self.assertEquals(list(f2.expiring_items()), [i3])
Ejemplo n.º 36
0
class SubtitleEncodingTest(MiroTestCase):
    def setUp(self):
        MiroTestCase.setUp(self)
        self.feed = Feed(u'http://example.com/1')
        self.item1 = Item(fp_values_for_url(u'http://example.com/1/item1'),
                          feed_id=self.feed.id)
        self.item2 = Item(fp_values_for_url(u'http://example.com/1/item2'),
                          feed_id=self.feed.id)

    def test_default(self):
        self.assertEquals(self.item1.subtitle_encoding, None)

    def test_set(self):
        self.item1.set_subtitle_encoding('latin-1')
        self.assertEquals(self.item1.subtitle_encoding, 'latin-1')

    def test_set_on_watched(self):
        # The 1st time an item is marked watched, we should remember the
        # subtitle encoding.
        self.item1.set_subtitle_encoding('latin-9')
        self.assertEquals(self.item2.subtitle_encoding, None)
        self.item2.mark_watched()
        self.assertEquals(self.item2.subtitle_encoding, 'latin-9')
        # Test the value isn't re-set the next time it's marked watched
        self.item1.set_subtitle_encoding('latin-5')
        self.item2.mark_watched()
        self.assertEquals(self.item2.subtitle_encoding, 'latin-9')

    def test_set_none(self):
        # Test an item is marked watched when the subtitle encoding is None)
        self.item1.mark_watched()
        self.assertEquals(self.item2.subtitle_encoding, None)
        self.item2.set_subtitle_encoding('latin-7')
        self.item2.mark_watched()
        self.item1.mark_watched()
        self.assertEquals(self.item1.subtitle_encoding, None)
Ejemplo n.º 37
0
    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),
        ]))
Ejemplo n.º 38
0
 def check_list(self, playlist, correct_order):
     correct_ids = [item.id for item in correct_order]
     actual_ids = list(i.id for i in Item.playlist_view(playlist.id))
     self.assertEquals(actual_ids, correct_ids)
Ejemplo n.º 39
0
 def check_guids(self, *ids):
     actual = set()
     for i in Item.make_view():
         actual.add(i.get_rss_id())
     correct = set(['guid-%d' % i for i in ids])
     self.assertEquals(actual, correct)
Ejemplo n.º 40
0
 def save_then_restore_db(self):
     self.reload_database(self.tempdb)
     self.feed = Feed.make_view().get_singleton()
     self.item = Item.make_view().get_singleton()
Ejemplo n.º 41
0
 def check_list(self, playlist, correct_order):
     correct_ids = [item.id for item in correct_order]
     actual_ids = list(i.id for i in Item.playlist_view(playlist.id))
     self.assertEquals(actual_ids, correct_ids)
Ejemplo n.º 42
0
    def test_live_storage_converts(self):
        # 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),
        ]))
Ejemplo n.º 43
0
    def test_get_auto_rating(self):
        feed = Feed(u'http://example.com/1')
        item = Item(fp_values_for_url(u'http://example.com/1/item1'),
                feed_id=feed.id)

        # no rating if it hasn't been played/skipped
        item.play_count = 0
        item.skip_count = 0
        self.assertEquals(item.get_auto_rating(), None)

        item.play_count = 0
        item.skip_count = 1
        self.assertEquals(item.get_auto_rating(), 1)

        item.play_count = 5
        item.skip_count = 5
        self.assertEquals(item.get_auto_rating(), 1)

        item.play_count = 5
        item.skip_count = 0
        self.assertEquals(item.get_auto_rating(), 5)
Ejemplo n.º 44
0
 def check_guids(self, *ids):
     actual = set()
     for i in Item.make_view():
         actual.add(i.get_rss_id())
     correct = set(['guid-%d' % i for i in ids])
     self.assertEquals(actual, correct)
Ejemplo n.º 45
0
 def make_regular_item(self, feed):
     url = u'http://example.com/1/item1'
     item = Item(fp_values_for_url(url), feed_id=feed.id)
     item.set_downloader(RemoteDownloader(url, item))
     return item
Ejemplo n.º 46
0
    def test_get_auto_rating(self):
        feed = Feed(u'http://example.com/1')
        item = Item(fp_values_for_url(u'http://example.com/1/item1'),
                    feed_id=feed.id)

        # no rating if it hasn't been played/skipped
        item.play_count = 0
        item.skip_count = 0
        self.assertEquals(item.get_auto_rating(), None)

        item.play_count = 0
        item.skip_count = 1
        self.assertEquals(item.get_auto_rating(), 1)

        item.play_count = 5
        item.skip_count = 5
        self.assertEquals(item.get_auto_rating(), 1)

        item.play_count = 5
        item.skip_count = 0
        self.assertEquals(item.get_auto_rating(), 5)
Ejemplo n.º 47
0
class SubtitleEncodingTest(MiroTestCase):
    def setUp(self):
        MiroTestCase.setUp(self)
        self.feed = Feed(u'http://example.com/1')
        self.item1 = Item(fp_values_for_url(u'http://example.com/1/item1'),
                feed_id=self.feed.id)
        self.item2 = Item(fp_values_for_url(u'http://example.com/1/item2'),
                feed_id=self.feed.id)

    def test_default(self):
        self.assertEquals(self.item1.subtitle_encoding, None)

    def test_set(self):
        self.item1.set_subtitle_encoding('latin-1')
        self.assertEquals(self.item1.subtitle_encoding, 'latin-1')

    def test_set_on_watched(self):
        # The 1st time an item is marked watched, we should remember the
        # subtitle encoding.
        self.item1.set_subtitle_encoding('latin-9')
        self.assertEquals(self.item2.subtitle_encoding, None)
        self.item2.mark_item_seen()
        self.assertEquals(self.item2.subtitle_encoding, 'latin-9')
        # Test the value isn't re-set the next time it's marked watched
        self.item1.set_subtitle_encoding('latin-5')
        self.item2.mark_item_seen()
        self.assertEquals(self.item2.subtitle_encoding, 'latin-9')

    def test_set_none(self):
        # Test an item is marked seen when the subtitle encoding is None)
        self.item1.mark_item_seen()
        self.assertEquals(self.item2.subtitle_encoding, None)
        self.item2.set_subtitle_encoding('latin-7')
        self.item2.mark_item_seen()
        self.item1.mark_item_seen()
        self.assertEquals(self.item1.subtitle_encoding, None)
Ejemplo n.º 48
0
 def make_regular_item(self, feed):
     url = u'http://example.com/1/item1'
     item = Item(fp_values_for_url(url), feed_id=feed.id)
     item.set_downloader(RemoteDownloader(url, item))
     return item
Ejemplo n.º 49
0
 def save_then_restore_db(self):
     self.reload_database(self.tempdb)
     self.feed = Feed.make_view().get_singleton()
     self.item = Item.make_view().get_singleton()
Ejemplo n.º 50
0
 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_)
Ejemplo n.º 51
0
 def make_item(self, url, title=u'default item title'):
     additional = {'title': title}
     entry = _build_entry(url, 'video/x-unknown', additional)
     item_ = Item(FeedParserValues(entry), feed_id=self.feed.id)
     self.items.append(item_)