本文整理汇总了Python中feed.Feed.load方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.load方法的具体用法?Python Feed.load怎么用?Python Feed.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feed.Feed
的用法示例。
在下文中一共展示了Feed.load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from feed import Feed [as 别名]
# 或者: from feed.Feed import load [as 别名]
def load(self, store):
for group in store.childGroups():
store.beginGroup(group)
feed = Feed()
feed.load(store)
self.feeds.append(feed)
store.endGroup()
示例2: articles
# 需要导入模块: from feed import Feed [as 别名]
# 或者: from feed.Feed import load [as 别名]
def articles():
from feed import Feed
# feed = Feed('data/2014-04-05_16-54.atom')
feed = Feed()
feed.load()
return feed.to_json()
示例3: FeedTest
# 需要导入模块: from feed import Feed [as 别名]
# 或者: from feed.Feed import load [as 别名]
class FeedTest(unittest2.TestCase):
def setUp(self):
import time
self.feed = Feed()
self.savefeed = Feed()
self.savefeed.title = "MyTitle"
self.savefeed.author = "MyAuthor"
self.savefeed.url = "MyUrl"
self.savefeed.homepage = "MyHomepage"
self.savefeed.updated = time.gmtime(time.time())
self.savefeed.deleted_entry_ids = ["123", "456"]
def testLoad(self):
import time
from base64 import b64encode
updated = time.gmtime(time.time())
store = StoreMock()
store.setValue("Title", "TestTitle")
store.setValue("Url", "TestUrl")
store.setValue("Homepage", "Homepage")
store.setValue("Author", "TestAuthor")
store.setValue("Updated", updated)
store.setValue("DeletedEntryIds", ["789","101112"])
store.beginGroup("Entry_%s" % b64encode("Id1"))
store.setValue("Title", "T1")
store.setValue("Updated", updated)
store.setValue("Author", "Author1")
store.setValue("Url", "Url1")
store.setValue("Id", "Id1")
store.setValue("Content", "Content1")
store.setValue("Read", True)
store.endGroup()
store.beginGroup("Entry_%s" % b64encode("Id2"))
store.setValue("Title", "T2")
store.setValue("Updated", updated)
store.setValue("Author", "Author2")
store.setValue("Url", "Url2")
store.setValue("Id", "Id2")
store.setValue("Content", "Content2")
store.endGroup()
self.savefeed.load(store)
self.assertEqual(self.savefeed.title, "TestTitle")
self.assertEqual(self.savefeed.updated, updated)
self.assertEqual(self.savefeed.url, "TestUrl")
self.assertEqual(self.savefeed.homepage, "Homepage")
self.assertEqual(self.savefeed.author, "TestAuthor")
self.assertEqual(self.savefeed.unread, 1)
self.assertEqual(len(self.savefeed.deleted_entry_ids), 2)
self.assertEqual(self.savefeed.deleted_entry_ids, ["789","101112"])
self.assertEqual(len(self.savefeed.entries), 2)
def testSave(self):
entry = Entry()
store = StoreMock()
self.savefeed.entries.append(entry)
self.savefeed.save(store)
self.assertEqual(len(store.childGroups()), 1)
self.assertEqual(self.savefeed.title, store.value("Title"))
self.assertEqual(self.savefeed.author, store.value("Author"))
self.assertEqual(self.savefeed.url, store.value("Url"))
self.assertEqual(self.savefeed.updated, store.value("Updated"))
self.assertEqual(self.savefeed.deleted_entry_ids, store.value("DeletedEntryIds", []))
def testTitle(self):
self.assertIsNone(self.feed.title)
self.feed.title = "test"
self.assertEqual(self.feed.title, "test")
def testAuthor(self):
self.assertIsNone(self.feed.author)
self.feed.author = "test"
self.assertEqual(self.feed.author, "test")
def testHomepage(self):
self.assertIsNone(self.feed.homepage)
self.feed.homepage = "test"
self.assertEqual(self.feed.homepage, "test")
def testFeedUrl(self):
self.assertIsNone(self.feed.url)
self.feed.url = "test"
self.assertEqual(self.feed.url, "test")
def testUpdated(self):
import time
self.assertEqual(self.feed.updated, None)
updated = time.gmtime(time.time())
self.feed.updated = updated
self.assertEqual(self.feed.updated, updated)
def testAdd(self):
self.assertEqual(len(self.feed.entries), 0)
self.feed.entries.append(Entry())
self.assertEqual(len(self.feed.entries), 1)
def testRemove(self):
self.assertEqual(len(self.feed.entries), 0)
self.assertEqual(len(self.feed.deleted_entry_ids), 0)
feed = Entry()
self.feed.entries.append(feed)
#.........这里部分代码省略.........