本文整理汇总了Python中miro.item.Item类的典型用法代码示例。如果您正苦于以下问题:Python Item类的具体用法?Python Item怎么用?Python Item使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Item类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:cool-RR,项目名称:Miro,代码行数:7,代码来源:feedtest.py
示例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)
开发者ID:cool-RR,项目名称:Miro,代码行数:7,代码来源:itemtest.py
示例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)
开发者ID:cool-RR,项目名称:Miro,代码行数:7,代码来源:itemtest.py
示例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)
开发者ID:CodeforEvolution,项目名称:miro,代码行数:8,代码来源:itemtest.py
示例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)
开发者ID:CodeforEvolution,项目名称:miro,代码行数:9,代码来源:itemtest.py
示例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()
开发者ID:cool-RR,项目名称:Miro,代码行数:9,代码来源:feedtest.py
示例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)
开发者ID:CodeforEvolution,项目名称:miro,代码行数:30,代码来源:itemtest.py
示例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)
开发者ID:kfatehi,项目名称:miro,代码行数:27,代码来源:itemtest.py
示例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])
开发者ID:kfatehi,项目名称:miro,代码行数:14,代码来源:itemtest.py
示例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())
开发者ID:kfatehi,项目名称:miro,代码行数:15,代码来源:itemtest.py
示例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])
开发者ID:kfatehi,项目名称:miro,代码行数:16,代码来源:itemtest.py
示例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)
开发者ID:cool-RR,项目名称:Miro,代码行数:8,代码来源:feedtest.py
示例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])
开发者ID:cool-RR,项目名称:Miro,代码行数:10,代码来源:playlisttest.py
示例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)
开发者ID:cool-RR,项目名称:Miro,代码行数:21,代码来源:feedtest.py
示例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)
开发者ID:CodeforEvolution,项目名称:miro,代码行数:10,代码来源:itemtest.py
示例16: test_change_in_setup_restored
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')
开发者ID:ShriramK,项目名称:miro,代码行数:19,代码来源:messagetest.py
示例17: check_list
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)
开发者ID:cool-RR,项目名称:Miro,代码行数:4,代码来源:playlisttest.py
示例18: 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
示例19: test_get_auto_rating
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)
开发者ID:CodeforEvolution,项目名称:miro,代码行数:21,代码来源:itemtest.py
示例20: SubtitleEncodingTest
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)
开发者ID:cool-RR,项目名称:Miro,代码行数:36,代码来源:itemtest.py
注:本文中的miro.item.Item类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论