本文整理汇总了Python中entry.Entry.save方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.save方法的具体用法?Python Entry.save怎么用?Python Entry.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entry.Entry
的用法示例。
在下文中一共展示了Entry.save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EntryTest
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import save [as 别名]
class EntryTest(unittest2.TestCase):
def setUp(self):
import time
self.entry = Entry()
self.saveentry = Entry()
self.saveentry.title = "TestTitle"
self.saveentry.author = "TestAuthor"
self.saveentry.url = "TestUrl"
self.saveentry.content = "TestContent"
self.saveentry.identity = "TestId"
self.saveentry.updated = time.gmtime(time.time())
self.saveentry.read = True
self.saveentry.important = True
def testTitle(self):
self.assertIsNone(self.entry.title)
self.entry.title = "test"
self.assertEqual(self.entry.title, "test")
def testUrl(self):
self.assertIsNone(self.entry.url)
self.entry.url = "test"
self.assertEqual(self.entry.url, "test")
def testImportant(self):
self.assertFalse(self.entry.important)
self.entry.important = True
self.assertTrue(self.entry.important)
def testAuthor(self):
self.assertIsNone(self.entry.author)
self.entry.author = "test"
self.assertEqual(self.entry.author, "test")
def testContent(self):
self.assertIsNone(self.entry.content)
self.entry.content = "test"
self.assertEqual(self.entry.content, "test")
def testIdentity(self):
self.assertIsNone(self.entry.identity)
self.entry.identity = "test"
self.assertEqual(self.entry.identity, "test")
def testUpdated(self):
import time
self.assertEqual(self.entry.updated, None)
update = time.gmtime(time.time())
self.entry.updated = update
self.assertEqual(self.entry.updated, update)
def testRead(self):
self.assertEqual(self.entry.read, False)
self.entry.read = True
self.assertEqual(self.entry.read, True)
def testLoad(self):
import time
store = StoreMock()
store.setValue("Title", "MyTitle")
store.setValue("Content", "MyContent")
updated = time.gmtime(time.time())
store.setValue("Updated", updated)
store.setValue("Url", "MyUrl")
store.setValue("Id", "MyId")
store.setValue("Author", "MyAuthor")
store.setValue("Read", True)
store.setValue("Important", True)
entry = Entry()
entry.load(store)
self.assertEqual(entry.title, "MyTitle")
self.assertEqual(entry.author, "MyAuthor")
self.assertEqual(entry.url, "MyUrl")
self.assertEqual(entry.identity, "MyId")
self.assertEqual(entry.updated, updated)
self.assertEqual(entry.content, "MyContent")
self.assertEqual(entry.read, True)
self.assertEqual(entry.important, True)
def testSave(self):
store = StoreMock()
self.saveentry.save(store)
self.assertEqual(store.value("Title"), self.saveentry.title)
self.assertEqual(store.value("Url"), self.saveentry.url)
self.assertEqual(store.value("Author"), self.saveentry.author)
self.assertEqual(store.value("Content"), self.saveentry.content)
self.assertEqual(store.value("Updated"), self.saveentry.updated)
self.assertEqual(store.value("Id"), self.saveentry.identity)
self.assertEqual(store.value("Read"), self.saveentry.read)
self.assertEqual(store.value("Important"), self.saveentry.important)
def testEqual(self):
entry = Entry()
entry.title = self.saveentry.title
entry.updated = self.saveentry.updated
entry.identity = self.saveentry.identity
entry.content = self.saveentry.content
entry.read = self.saveentry.read
entry.url = self.saveentry.url
entry.important = self.saveentry.important
#.........这里部分代码省略.........