本文整理汇总了Python中miro.item.Item类的典型用法代码示例。如果您正苦于以下问题:Python Item类的具体用法?Python Item怎么用?Python Item使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Item类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simple_overflow
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)
示例2: setUp
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)
示例3: test_watched_time_reset
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)
示例4: test_set_rating
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)
示例5: test_strips_tags
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)
示例6: test_run
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()
示例7: ItemSearchTest
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)
示例8: ItemSearchTest
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)
示例9: test_expired_view_3
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])
示例10: test_remove_before_downloader_referenced
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())
示例11: test_expired_view_2
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])
示例12: test_overflow_with_downloads
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)
示例13: 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])
示例14: test_overflow_with_global_max_old_items
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)
示例15: check_have_item_for_path
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)