当前位置: 首页>>代码示例>>Python>>正文


Python Changeset.get_id方法代码示例

本文整理汇总了Python中majormajor.changeset.Changeset.get_id方法的典型用法代码示例。如果您正苦于以下问题:Python Changeset.get_id方法的具体用法?Python Changeset.get_id怎么用?Python Changeset.get_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在majormajor.changeset.Changeset的用法示例。


在下文中一共展示了Changeset.get_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_dependency_ids

# 需要导入模块: from majormajor.changeset import Changeset [as 别名]
# 或者: from majormajor.changeset.Changeset import get_id [as 别名]
 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']
开发者ID:citizencurator,项目名称:majormajor,代码行数:14,代码来源:test_changeset_helpers.py

示例2: test_set_id

# 需要导入模块: from majormajor.changeset import Changeset [as 别名]
# 或者: from majormajor.changeset.Changeset import get_id [as 别名]
 def test_set_id(self):
     cs0 = Changeset('doc_id', 'user_id', [])
     assert cs0.set_id('randomid')
     assert cs0.get_id() == 'randomid'
开发者ID:citizencurator,项目名称:majormajor,代码行数:6,代码来源:test_changeset_helpers.py

示例3: setup_method

# 需要导入模块: from majormajor.changeset import Changeset [as 别名]
# 或者: from majormajor.changeset.Changeset import get_id [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
              /         /            \
#.........这里部分代码省略.........
开发者ID:citizencurator,项目名称:majormajor,代码行数:103,代码来源:test_changeset_helpers.py


注:本文中的majormajor.changeset.Changeset.get_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。