當前位置: 首頁>>代碼示例>>Python>>正文


Python Connector.parents方法代碼示例

本文整理匯總了Python中peerdrive.Connector.parents方法的典型用法代碼示例。如果您正苦於以下問題:Python Connector.parents方法的具體用法?Python Connector.parents怎麽用?Python Connector.parents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在peerdrive.Connector的用法示例。


在下文中一共展示了Connector.parents方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_suspend_multi

# 需要導入模塊: from peerdrive import Connector [as 別名]
# 或者: from peerdrive.Connector import parents [as 別名]
	def test_suspend_multi(self):
		(doc, rev1, rev_s1) = self.createSuspendDoc()

		with Connector().update(self.store1, doc, rev1) as w:
			w.writeAll('FILE', 'forward')
			w.commit()
			rev2 = w.getRev()

		with Connector().update(self.store1, doc, rev2) as w:
			w.writeAll('FILE', 'Hail to the king, baby!')
			w.suspend()
			rev_s2 = w.getRev()

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev2])
		self.assertEqual(len(l.preRevs()), 2)
		self.assertTrue(rev_s1 in l.preRevs())
		self.assertTrue(rev_s2 in l.preRevs())

		s = Connector().stat(rev_s1)
		self.assertEqual(s.parents(), [rev1])
		s = Connector().stat(rev_s2)
		self.assertEqual(s.parents(), [rev2])

		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev_s1, {'FILE' : 'update'})
		self.assertRevContent(self.store1, rev2, {'FILE' : 'forward'})
		self.assertRevContent(self.store1, rev_s2, {'FILE' : 'Hail to the king, baby!'})
開發者ID:wizzk42,項目名稱:peerdrive,代碼行數:30,代碼來源:tests.py

示例2: test_sync_merge

# 需要導入模塊: from peerdrive import Connector [as 別名]
# 或者: from peerdrive.Connector import parents [as 別名]
    def test_sync_merge(self):
        (doc, rev1, rev2) = self.createMerge(
            "org.peerdrive.folder",
            {"META": struct.dumps({"a": 1}), "PDSD": struct.dumps([{"": 1}, {"": 2}])},
            {"META": struct.dumps({"a": 4, "b": 2}), "PDSD": struct.dumps([{"": 1}, {"": 2}, {"": 3}])},
            {"META": struct.dumps({"a": 1, "c": 3}), "PDSD": struct.dumps([{"": 2}])},
        )
        l = self.performSync(doc, "merge")

        rev = l.revs()[0]
        s = Connector().stat(rev)
        self.assertEqual(len(s.parents()), 2)
        self.assertTrue(rev1 in s.parents())
        self.assertTrue(rev2 in s.parents())

        # all revs on all stores?
        l = Connector().lookupRev(rev1)
        self.assertTrue(self.store1 in l)
        self.assertTrue(self.store2 in l)
        l = Connector().lookupRev(rev2)
        self.assertTrue(self.store1 in l)
        self.assertTrue(self.store2 in l)

        # see if merge was ok
        with Connector().peek(self.store1, rev) as r:
            meta = struct.loads(self.store1, r.readAll("META"))
            if "org.peerdrive.annotation" in meta:
                del meta["org.peerdrive.annotation"]
            self.assertEqual(meta, {"a": 4, "b": 2, "c": 3})
            pdsd = sorted(struct.loads(self.store1, r.readAll("PDSD")))
            self.assertEqual(pdsd, [{"": 2}, {"": 3}])
開發者ID:peerdrive,項目名稱:peerdrive,代碼行數:33,代碼來源:tests.py

示例3: test_sync_merge_fallback

# 需要導入模塊: from peerdrive import Connector [as 別名]
# 或者: from peerdrive.Connector import parents [as 別名]
    def test_sync_merge_fallback(self):
        (doc, rev1, rev2) = self.createMerge("public.data", {}, {"FILE": "left3"}, {"FILE": "right3"})
        l = self.performSync(doc, "merge")

        rev = l.revs()[0]
        s = Connector().stat(rev)
        self.assertEqual(len(s.parents()), 2)
        self.assertTrue(rev1 in s.parents())
        self.assertTrue(rev2 in s.parents())
        self.assertRevContent(self.store1, rev, {"FILE": "left3"})
開發者ID:peerdrive,項目名稱:peerdrive,代碼行數:12,代碼來源:tests.py

示例4: test_sync_latest

# 需要導入模塊: from peerdrive import Connector [as 別名]
# 或者: from peerdrive.Connector import parents [as 別名]
	def test_sync_latest(self):
		(doc, rev1, rev2) = self.createMerge("public.data", {}, {'FILE' : "left2"},
			{'FILE' : "right2"})
		l = self.performSync(doc, 'latest')

		rev = l.revs()[0]
		s = Connector().stat(rev)
		self.assertEqual(len(s.parents()), 2)
		self.assertTrue(rev1 in s.parents())
		self.assertTrue(rev2 in s.parents())
		self.assertRevContent(self.store1, rev, {'FILE' : 'left2'})
開發者ID:wizzk42,項目名稱:peerdrive,代碼行數:13,代碼來源:tests.py

示例5: test_resume_suspend_orig

# 需要導入模塊: from peerdrive import Connector [as 別名]
# 或者: from peerdrive.Connector import parents [as 別名]
	def test_resume_suspend_orig(self):
		(doc, rev1, rev2) = self.createSuspendDoc()

		with Connector().resume(self.store1, doc, rev2) as w:
			w.suspend()
			rev3 = w.getRev()

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev1])
		self.assertEqual(l.preRevs(), [rev3])

		s = Connector().stat(rev3)
		self.assertEqual(s.parents(), [rev1])

		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev3, {'FILE' : 'update'})
開發者ID:wizzk42,項目名稱:peerdrive,代碼行數:18,代碼來源:tests.py

示例6: test_resume_commit

# 需要導入模塊: from peerdrive import Connector [as 別名]
# 或者: from peerdrive.Connector import parents [as 別名]
	def test_resume_commit(self):
		(doc, rev1, rev2) = self.createSuspendDoc()

		with Connector().resume(self.store1, doc, rev2) as w:
			w.writeAll('FILE', 'What are you waiting for, christmas?')
			w.commit()
			rev3 = w.getRev()

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev3])
		self.assertEqual(len(l.preRevs()), 0)

		s = Connector().stat(rev3)
		self.assertEqual(s.parents(), [rev1])
		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev3, {'FILE' : 'What are you waiting for, christmas?'})
開發者ID:wizzk42,項目名稱:peerdrive,代碼行數:18,代碼來源:tests.py

示例7: __update

# 需要導入模塊: from peerdrive import Connector [as 別名]
# 或者: from peerdrive.Connector import parents [as 別名]
	def __update(self):
		if self.__seen:
			self.__unwatch()
			self.__available = len(Connector().lookupRev(self.__rev)) > 0
		else:
			self.__available = False
			try:
				stat = Connector().stat(self.__rev)
				self.__mtime = stat.mtime()
				self.__seen = True
				self.__available = True
				self.__view._addParents(stat.parents())
				self.__unwatch()
			except IOError:
				self.__watch()
				return
開發者ID:wizzk42,項目名稱:peerdrive,代碼行數:18,代碼來源:org.peerdrive.browser.py

示例8: test_resume_suspend_mod

# 需要導入模塊: from peerdrive import Connector [as 別名]
# 或者: from peerdrive.Connector import parents [as 別名]
    def test_resume_suspend_mod(self):
        (doc, rev1, rev2) = self.createSuspendDoc()

        with Connector().resume(self.store1, doc, rev2) as w:
            w.writeAll("FILE", "What are you waiting for, christmas?")
            w.suspend()
            rev3 = w.getRev()

        l = Connector().lookupDoc(doc)
        self.assertEqual(l.revs(), [rev1])
        self.assertEqual(l.preRevs(), [rev3])

        s = Connector().stat(rev3)
        self.assertEqual(s.parents(), [rev1])

        self.assertRevContent(self.store1, rev1, {"FILE": "ok"})
        self.assertRevContent(self.store1, rev3, {"FILE": "What are you waiting for, christmas?"})
開發者ID:peerdrive,項目名稱:peerdrive,代碼行數:19,代碼來源:tests.py


注:本文中的peerdrive.Connector.parents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。