def setUp(self): MiroTestCase.setUp(self) self.manual_feed = Feed(u'dtv:manualFeed') self.regular_feed = Feed(u'http://example.com/1') self.path, fp = self.make_temp_path_fileobj(".avi") fp.write("fake data") fp.close()
def test_added_order(self): f1 = Feed(u'http://example.com/3') f2 = Feed(u'http://example.com/4') f3 = Feed(u'http://example.com/5') f4 = Feed(u'http://example.com/6') f5 = Feed(u'http://example.com/7') self.runUrgentCalls() # We want the ChannelAdded messages to come in the same order # the feeds were added self.check_changed_message(1, added=[f1, f2, f3, f4, f5])
def setUp(self): TrackerTest.setUp(self) self.feed1 = Feed(u'http://example.com/') self.feed2 = Feed(u'http://example.com/2') self.feed_folder = ChannelFolder(u'test channel folder') m = messages.TabsReordered() m.toplevels['feed'] = [messages.ChannelInfo(self.feed1), messages.ChannelInfo(self.feed_folder)] m.folder_children[self.feed_folder.id] = \ [messages.ChannelInfo(self.feed2)] m.send_to_backend() messages.TrackChannels().send_to_backend() self.runUrgentCalls()
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.watchedTime = i2.watchedTime = datetime.now() for obj in (f1, i1, i2): obj.signal_change() self.assertEquals(list(f1.expiring_items()), [])
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])
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()), [])
def setUp(self): TrackerTest.setUp(self) self.feed1 = Feed(u'http://example.com/') self.feed2 = Feed(u'http://example.com/2') self.feed_folder = ChannelFolder(u'test channel folder') m = messages.TabsReordered() m.toplevels['feed'] = [ messages.ChannelInfo(self.feed1), messages.ChannelInfo(self.feed_folder) ] m.folder_children[self.feed_folder.id] = \ [messages.ChannelInfo(self.feed2)] m.send_to_backend() messages.TrackChannels().send_to_backend() self.runUrgentCalls()
def test_make_item_for_nonexistent_path(self): feed = Feed(u'dtv:manualFeed', initiallyAutoDownloadable=False) # test that creating a file item for a path that doesn't exist doesn't # cause a crash. A soft failure is okay though. app.controller.failed_soft_okay = True Item._allow_nonexistent_paths = False FileItem("/non/existent/path/", feed.id)
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])
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])
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_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)
def setUp(self): MiroTestCase.setUp(self) self.items = [] self.feed = Feed(u'dtv:manualFeed') self.items = [ testobjects.make_item(self.feed, u'item-1'), testobjects.make_item(self.feed, u'item-2'), ]
def test_stop(self): self.check_message_count(1) messages.StopTrackingChannels().send_to_backend() self.runUrgentCalls() self.feed1.set_title(u"Booya") Feed(u'http://example.com/3') self.feed2.remove() self.check_message_count(1)
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)
def setUp(self): TrackerTest.setUp(self) self.items = [] self.feed = Feed(u'dtv:manualFeed') self.make_item(u'http://example.com/', u'my first item') self.make_item(u'http://example.com/2', u'my second item') self.runUrgentCalls() messages.TrackItems('feed', self.feed.id).send_to_backend() self.runUrgentCalls()
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])
def test_reduce_number_of_messages(self): f1 = Feed(u'http://example.com/3') f1.remove() f2 = Feed(u'http://example.com/4') f2.set_title(u'New Title') self.runUrgentCalls() # We don't need to see that f1 was added because it got # removed immediately after. We don't need to see that f2 was # changed because it will have the updated info in added. self.check_message_count(2) self.check_changed_message(1, added=[f2])
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 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)
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)
def setUp(self): EventLoopTest.setUp(self) Feed(u'dtv:search') self.test_handler = TestFrontendMessageHandler() messages.FrontendMessage.install_handler(self.test_handler) self.backend_message_handler = messagehandler.BackendMessageHandler( None) messages.BackendMessage.install_handler(self.backend_message_handler) self.channelTabOrder = TabOrder(u'channel') self.playlistTabOrder = TabOrder(u'playlist') # Adding a guide ensures that if we remove all our # channel/playlist tabs the selection code won't go crazy. self.guide = ChannelGuide(app.config.get(prefs.CHANNEL_GUIDE_URL))
def setUp(self): MiroTestCase.setUp(self) self.feed = Feed(u'dtv:manualFeed', initiallyAutoDownloadable=False) self.mytempdir = FilenameType(tempfile.mkdtemp(dir=self.tempdir)) self._make_fake_item("pcf.avi") self._make_fake_item("dean.avi") self._make_fake_item("npr.txt") self.container_item = FileItem(self.mytempdir, self.feed.id) for child in self.container_item.get_children(): if child.filename.endswith("avi"): child.file_type = u'video' else: child.file_type = u'other' child.signal_change()
def setUp(self): EventLoopTest.setUp(self) self.feed = Feed(u'dtv:manualFeed', initiallyAutoDownloadable=False) self.mytempdir = FilenameType(tempfile.mkdtemp(dir=self.tempdir)) self._make_fake_item("pcf.avi") self._make_fake_item("dean.avi") self._make_fake_item("npr.txt") self.container_item = FileItem(self.mytempdir, self.feed.id) # Give the iterators some time to run self.process_idles() for child in self.container_item.get_children(): if child.filename.endswith("avi"): child.file_type = u'video' else: child.file_type = u'other' child.signal_change()
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())
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)
def setUp(self): MiroTestCase.setUp(self) self.items = [] self.feed = Feed(u'dtv:manualFeed') self.make_item(u'http://example.com/') self.make_item(u'http://example.com/2')
def make_feed(self): feed = Feed(self.url) self.update_feed(feed) return feed
def test_added(self): f = Feed(u'http://example.com/3') self.runUrgentCalls() self.check_message_count(2) self.check_changed_message(1, added=[f])
class FeedTrackTest(TrackerTest): def setUp(self): TrackerTest.setUp(self) self.feed1 = Feed(u'http://example.com/') self.feed2 = Feed(u'http://example.com/2') self.feed_folder = ChannelFolder(u'test channel folder') m = messages.TabsReordered() m.toplevels['feed'] = [messages.ChannelInfo(self.feed1), messages.ChannelInfo(self.feed_folder)] m.folder_children[self.feed_folder.id] = \ [messages.ChannelInfo(self.feed2)] m.send_to_backend() messages.TrackChannels().send_to_backend() self.runUrgentCalls() def check_info(self, channelInfo, feed): self.assertEquals(channelInfo.name, feed.get_title()) self.assertEquals(channelInfo.id, feed.id) self.assertEquals(channelInfo.unwatched, feed.num_unwatched()) self.assertEquals(channelInfo.available, feed.num_available()) self.assertEquals(channelInfo.is_folder, isinstance(feed, ChannelFolder)) def check_changed_message_type(self, message): self.assertEquals(type(message), messages.TabsChanged) self.assertEquals(message.type, 'feed') def test_initial_list(self): self.check_message_count(1) message1 = self.test_handler.messages[0] self.assert_(isinstance(message1, messages.TabList)) self.assertEquals(message1.type, 'feed') self.check_info_list(message1.toplevels, [self.feed1, self.feed_folder]) self.check_info_list(message1.folder_children[self.feed_folder.id], [self.feed2]) self.assertEquals(len(message1.folder_children), 1) def test_added(self): f = Feed(u'http://example.com/3') self.runUrgentCalls() self.check_message_count(2) self.check_changed_message(1, added=[f]) def test_added_order(self): f1 = Feed(u'http://example.com/3') f2 = Feed(u'http://example.com/4') f3 = Feed(u'http://example.com/5') f4 = Feed(u'http://example.com/6') f5 = Feed(u'http://example.com/7') self.runUrgentCalls() # We want the ChannelAdded messages to come in the same order # the feeds were added self.check_changed_message(1, added=[f1, f2, f3, f4, f5]) @uses_httpclient def test_removed(self): self.feed2.remove() self.runUrgentCalls() self.check_message_count(2) self.check_changed_message(1, removed=[self.feed2]) def test_change(self): self.feed1.set_title(u"Booya") self.runUrgentCalls() self.check_message_count(2) self.check_changed_message(1, changed=[self.feed1]) @uses_httpclient def test_reduce_number_of_messages(self): f1 = Feed(u'http://example.com/3') f1.remove() f2 = Feed(u'http://example.com/4') f2.set_title(u'New Title') self.runUrgentCalls() # We don't need to see that f1 was added because it got # removed immediately after. We don't need to see that f2 was # changed because it will have the updated info in added. self.check_message_count(2) self.check_changed_message(1, added=[f2]) @uses_httpclient def test_stop(self): self.check_message_count(1) messages.StopTrackingChannels().send_to_backend() self.runUrgentCalls() self.feed1.set_title(u"Booya") Feed(u'http://example.com/3') self.feed2.remove() self.check_message_count(1)
class FeedTrackTest(TrackerTest): def setUp(self): TrackerTest.setUp(self) self.feed1 = Feed(u'http://example.com/') self.feed2 = Feed(u'http://example.com/2') self.feed_folder = ChannelFolder(u'test channel folder') m = messages.TabsReordered() m.toplevels['feed'] = [ messages.ChannelInfo(self.feed1), messages.ChannelInfo(self.feed_folder) ] m.folder_children[self.feed_folder.id] = \ [messages.ChannelInfo(self.feed2)] m.send_to_backend() messages.TrackChannels().send_to_backend() self.runUrgentCalls() def check_info(self, channelInfo, feed): self.assertEquals(channelInfo.name, feed.get_title()) self.assertEquals(channelInfo.id, feed.id) self.assertEquals(channelInfo.unwatched, feed.num_unwatched()) self.assertEquals(channelInfo.available, feed.num_available()) self.assertEquals(channelInfo.is_folder, isinstance(feed, ChannelFolder)) def check_changed_message_type(self, message): self.assertEquals(type(message), messages.TabsChanged) self.assertEquals(message.type, 'feed') def test_initial_list(self): self.check_message_count(1) message1 = self.test_handler.messages[0] self.assert_(isinstance(message1, messages.TabList)) self.assertEquals(message1.type, 'feed') self.check_info_list(message1.toplevels, [self.feed1, self.feed_folder]) self.check_info_list(message1.folder_children[self.feed_folder.id], [self.feed2]) self.assertEquals(len(message1.folder_children), 1) def test_added(self): f = Feed(u'http://example.com/3') self.runUrgentCalls() self.check_message_count(2) self.check_changed_message(1, added=[f]) def test_added_order(self): f1 = Feed(u'http://example.com/3') f2 = Feed(u'http://example.com/4') f3 = Feed(u'http://example.com/5') f4 = Feed(u'http://example.com/6') f5 = Feed(u'http://example.com/7') self.runUrgentCalls() # We want the ChannelAdded messages to come in the same order # the feeds were added self.check_changed_message(1, added=[f1, f2, f3, f4, f5]) @uses_httpclient def test_removed(self): self.feed2.remove() self.runUrgentCalls() self.check_message_count(2) self.check_changed_message(1, removed=[self.feed2]) def test_change(self): self.feed1.set_title(u"Booya") self.runUrgentCalls() self.check_message_count(2) self.check_changed_message(1, changed=[self.feed1]) @uses_httpclient def test_reduce_number_of_messages(self): f1 = Feed(u'http://example.com/3') f1.remove() f2 = Feed(u'http://example.com/4') f2.set_title(u'New Title') self.runUrgentCalls() # We don't need to see that f1 was added because it got # removed immediately after. We don't need to see that f2 was # changed because it will have the updated info in added. self.check_message_count(2) self.check_changed_message(1, added=[f2]) @uses_httpclient def test_stop(self): self.check_message_count(1) messages.StopTrackingChannels().send_to_backend() self.runUrgentCalls() self.feed1.set_title(u"Booya") Feed(u'http://example.com/3') self.feed2.remove() self.check_message_count(1)
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()
def setUp(self): MiroTestCase.setUp(self) self.feed = Feed(u'http://example.com/1') self.added_items = {} self.deleted_paths = []