本文整理汇总了Python中majormajor.changeset.Changeset.relink_changesets方法的典型用法代码示例。如果您正苦于以下问题:Python Changeset.relink_changesets方法的具体用法?Python Changeset.relink_changesets怎么用?Python Changeset.relink_changesets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类majormajor.changeset.Changeset
的用法示例。
在下文中一共展示了Changeset.relink_changesets方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_has_needed_dependencies
# 需要导入模块: from majormajor.changeset import Changeset [as 别名]
# 或者: from majormajor.changeset.Changeset import relink_changesets [as 别名]
def test_has_needed_dependencies(self):
doc = self.doc0
cs1 = Changeset(doc.get_id(), 'user', [doc.get_root_changeset()])
assert doc.has_needed_dependencies(cs1)
cs2 = Changeset(doc.get_id(), 'user', [cs1])
assert not doc.has_needed_dependencies(cs2)
doc.receive_changeset(cs1)
assert doc.has_needed_dependencies(cs2)
cs3 = Changeset(doc.get_id(), 'user', [cs1, cs2])
assert not doc.has_needed_dependencies(cs3)
doc.receive_changeset(cs2)
assert doc.has_needed_dependencies(cs3)
cs4 = Changeset(doc.get_id(), 'user', [cs3, "555"])
assert not doc.has_needed_dependencies(cs4)
doc.receive_changeset(cs3)
assert not doc.has_needed_dependencies(cs4)
cs5 = Changeset(doc.get_id(), 'user', [cs1])
cs5.set_id("555")
doc.receive_changeset(cs5)
cs4.relink_changesets(doc.all_known_changesets)
assert cs5 in cs4.get_parents()
assert cs4.has_full_dependency_info()
assert doc.has_needed_dependencies(cs4)
示例2: xtest_relink_dependency
# 需要导入模块: from majormajor.changeset import Changeset [as 别名]
# 或者: from majormajor.changeset.Changeset import relink_changesets [as 别名]
def xtest_relink_dependency(self):
dep = Changeset('doc_id', 'user_id', [])
dep.set_id('defined_id')
# a cs with no dependencies should never relink
assert not self.cs0.relink_changesets(dep)
# cs does not need given dep
cs1 = Changeset('doc_id', 'user_id', [self.cs0])
assert not cs1.relink_changesets(dep)
assert cs1.get_dependencies() == [self.cs0]
# cs already has given dep info
cs2 = Changeset('doc_id', 'user_id', [self.cs0, dep])
assert not cs2.relink_changesets(dep)
assert cs2.get_dependencies() == [self.cs0, dep]
# cs needed and relinked given dep
cs3 = Changeset('doc_id', 'user_id', [self.cs0, 'defined_id'])
assert cs3.relink_changesets(dep)
assert cs3.get_dependencies() == [self.cs0, dep]
示例3: setup_method
# 需要导入模块: from majormajor.changeset import Changeset [as 别名]
# 或者: from majormajor.changeset.Changeset import relink_changesets [as 别名]
class TestChangesetHelpers:
def setup_method(self, method):
self.cs0 = Changeset('doc_id', 'user_id', [])
def test_is_empty(self):
cs = Changeset('doc_id', 'user_id', [])
assert cs.is_empty()
cs.add_op(Op('set',[],val=''))
assert not cs.is_empty()
def test_has_full_dependency_info(self):
# should always pass when it has no dependencies
cs0 = Changeset('doc_id', 'user_id', [])
assert cs0.has_full_dependency_info()
cs1 = Changeset('doc_id', 'user_id', ['randomid'])
assert not cs1.has_full_dependency_info()
cs2 = Changeset('doc_id', 'user_id', [cs1])
assert cs2.has_full_dependency_info()
cs3 = Changeset('doc_id', 'user_id', [cs2, 'otherrandomid'])
assert not cs3.has_full_dependency_info()
cs4 = Changeset('doc_id', 'user_id', [cs1])
cs5 = Changeset('doc_id', 'user_id', [cs4, cs3])
assert cs5.has_full_dependency_info()
cs6 = Changeset('doc_id', 'user_id', [cs5, 'otherid'])
assert not cs6.has_full_dependency_info()
def test_get_dependency_ids(self):
cs0 = Changeset('doc_id', 'user_id', [])
assert cs0.get_dependency_ids() == []
cs1 = Changeset('doc_id', 'user_id', ['randomid'])
assert cs1.get_dependency_ids() == ['randomid']
cs2 = Changeset('doc_id', 'user_id', [cs1])
assert cs2.get_dependency_ids() == [cs1.get_id()]
cs3 = Changeset('doc_id', 'user_id', [cs2, 'otherrandomid'])
assert cs3.get_dependency_ids() == [cs2.get_id(), 'otherrandomid']
def test_set_id(self):
cs0 = Changeset('doc_id', 'user_id', [])
assert cs0.set_id('randomid')
assert cs0.get_id() == 'randomid'
def test_add_op(self):
op = Op('set', [],val='')
assert self.cs0.add_op(op)
assert self.cs0.get_ops() == [op]
# cannot add same op twice
with pytest.raises(Exception):
self.cs0.add_op(op)
# add a differant op and it goes through
op2 = Op('set', [],val='')
assert self.cs0.add_op(op2)
assert self.cs0.get_ops() == [op, op2]
# once id is set, cannot add more ops
self.cs0.get_id()
op3 = Op('set', [],val='')
with pytest.raises(Exception):
self.cs0.add_op(op3)
def xtest_relink_dependency(self):
dep = Changeset('doc_id', 'user_id', [])
dep.set_id('defined_id')
# a cs with no dependencies should never relink
assert not self.cs0.relink_changesets(dep)
# cs does not need given dep
cs1 = Changeset('doc_id', 'user_id', [self.cs0])
assert not cs1.relink_changesets(dep)
assert cs1.get_dependencies() == [self.cs0]
# cs already has given dep info
cs2 = Changeset('doc_id', 'user_id', [self.cs0, dep])
assert not cs2.relink_changesets(dep)
assert cs2.get_dependencies() == [self.cs0, dep]
# cs needed and relinked given dep
cs3 = Changeset('doc_id', 'user_id', [self.cs0, 'defined_id'])
assert cs3.relink_changesets(dep)
assert cs3.get_dependencies() == [self.cs0, dep]
def test_has_ancestor(self):
"""
Some complex tree.
C -- G -- H -------- K
/ / \
#.........这里部分代码省略.........