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


Python CurrentView._stage方法代码示例

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


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

示例1: test_rename

# 需要导入模块: from gitfs.views.current import CurrentView [as 别名]
# 或者: from gitfs.views.current.CurrentView import _stage [as 别名]
    def test_rename(self):
        mocked_re = MagicMock()
        mocked_index = MagicMock()
        mocked_os = MagicMock()
        mocked_result = MagicMock()

        mocked_result.rename.return_value = True
        mocked_re.sub.return_value = "new"
        mocked_os.path.split.return_value = [1, 1]

        with patch.multiple('gitfs.views.current', re=mocked_re,
                            os=mocked_os):
            from gitfs.views import current as current_view
            old_rename = current_view.PassthroughView.rename
            current_view.PassthroughView.rename = lambda self, old, new: True

            current = CurrentView(regex="regex", repo="repo",
                                  repo_path="repo_path",
                                  ignore=CachedIgnore())
            current._stage = mocked_index

            result = current.rename("old", "new")
            assert result is True
            mocked_index.assert_called_once_with(**{
                'remove': 1,
                'add': "new",
                "message": "Rename old to new"
            })
            mocked_os.path.split.assert_called_once_with("old")
            current_view.PassthroughView.rename = old_rename
开发者ID:Marius786,项目名称:gitfs,代码行数:32,代码来源:test_current.py

示例2: test_stage

# 需要导入模块: from gitfs.views.current import CurrentView [as 别名]
# 或者: from gitfs.views.current.CurrentView import _stage [as 别名]
    def test_stage(self):
        mocked_repo = MagicMock()
        mocked_sanitize = MagicMock()
        mocked_queue = MagicMock()

        mocked_sanitize.return_value = ["to-stage"]

        current = CurrentView(repo=mocked_repo,
                              repo_path="repo_path",
                              queue=mocked_queue, ignore=CachedIgnore("f"))
        current._sanitize = mocked_sanitize
        current._stage("message", ["add"], ["remove"])

        mocked_queue.commit.assert_called_once_with(add=['to-stage'],
                                                    remove=['to-stage'],
                                                    message="message")
        mocked_repo.index.add.assert_called_once_with(["to-stage"])
        mocked_repo.index.remove.assert_called_once_with(["to-stage"])

        mocked_sanitize.has_calls([call(['add']), call(['remove'])])
开发者ID:calind,项目名称:gitfs,代码行数:22,代码来源:test_current.py

示例3: test_unlink

# 需要导入模块: from gitfs.views.current import CurrentView [as 别名]
# 或者: from gitfs.views.current.CurrentView import _stage [as 别名]
    def test_unlink(self):
        from gitfs.views import current as current_view
        old_unlink = current_view.PassthroughView.unlink
        current_view.PassthroughView.unlink = lambda me, path: "done"

        mocked_index = MagicMock()

        current = CurrentView(repo="repo", uid=1, gid=1,
                              repo_path="repo_path",
                              ignore=CachedIgnore())
        current._stage = mocked_index

        assert current.unlink("/path") == "done"
        message = "Deleted /path"
        mocked_index.assert_called_once_with(remove="/path", message=message)

        current_view.PassthroughView.unlink = old_unlink
开发者ID:Marius786,项目名称:gitfs,代码行数:19,代码来源:test_current.py

示例4: test_fsync

# 需要导入模块: from gitfs.views.current import CurrentView [as 别名]
# 或者: from gitfs.views.current.CurrentView import _stage [as 别名]
    def test_fsync(self):
        from gitfs.views import current as current_view
        old_fsync = current_view.PassthroughView.fsync
        current_view.PassthroughView.fsync = lambda me, path, data, fh: "done"

        mocked_index = MagicMock()

        current = CurrentView(repo="repo", uid=1, gid=1,
                              repo_path="repo_path",
                              ignore=CachedIgnore())
        current._stage = mocked_index

        assert current.fsync("/path", "data", 1) == "done"
        message = "Fsync /path"
        mocked_index.assert_called_once_with(add="/path", message=message)

        current_view.PassthroughView.fsync = old_fsync
开发者ID:Marius786,项目名称:gitfs,代码行数:19,代码来源:test_current.py

示例5: test_symlink

# 需要导入模块: from gitfs.views.current import CurrentView [as 别名]
# 或者: from gitfs.views.current.CurrentView import _stage [as 别名]
    def test_symlink(self):
        mocked_index = MagicMock()
        mocked_repo = MagicMock()
        mocked_full_path = MagicMock()

        mocked_full_path.return_value = "full_path"
        mocked_repo._full_path = mocked_full_path

        with patch('gitfs.views.current.os') as mocked_os:
            mocked_os.symlink.return_value = "done"

            current = CurrentView(repo=mocked_repo, repo_path="repo_path",
                                  ignore=CachedIgnore())
            current._stage = mocked_index

            assert current.symlink("name", "target") == "done"
            mocked_os.symlink.assert_called_once_with("target", "full_path")
            mocked_full_path.assert_called_once_with("name")
            message = "Create symlink to target for name"
            mocked_index.assert_called_once_with(add="name", message=message)
开发者ID:Marius786,项目名称:gitfs,代码行数:22,代码来源:test_current.py

示例6: test_chmod

# 需要导入模块: from gitfs.views.current import CurrentView [as 别名]
# 或者: from gitfs.views.current.CurrentView import _stage [as 别名]
    def test_chmod(self):
        from gitfs.views import current as current_view
        old_chmod = current_view.PassthroughView.chmod
        current_view.PassthroughView.chmod = lambda self, path, mode: "done"

        mocked_index = MagicMock()
        mocked_full = MagicMock(return_value="/path")
        mocked_repo = MagicMock(_full_path=mocked_full)

        current = CurrentView(repo=mocked_repo, uid=1, gid=1,
                              repo_path="repo_path",
                              ignore=CachedIgnore())

        current._stage = mocked_index

        assert current.chmod("/path", 0100644) == "done"
        message = 'Chmod to %s on %s' % (str(oct(0644))[-4:], "/path")
        mocked_index.assert_called_once_with(add="/path", message=message)

        current_view.PassthroughView.chmod = old_chmod
开发者ID:AlexSnet,项目名称:gitfs,代码行数:22,代码来源:test_current.py

示例7: test_release

# 需要导入模块: from gitfs.views.current import CurrentView [as 别名]
# 或者: from gitfs.views.current.CurrentView import _stage [as 别名]
    def test_release(self):
        message = "I need to stage this"
        mocked_os = MagicMock()
        mocked_stage = MagicMock()

        mocked_os.close.return_value = 0

        with patch.multiple('gitfs.views.current', os=mocked_os):
            current = CurrentView(repo="repo",
                                  repo_path="repo_path",
                                  ignore=CachedIgnore())
            current._stage = mocked_stage
            current.dirty = {
                4: {
                    'message': message
                }
            }

            assert current.release("/path", 4) == 0

            mocked_os.close.assert_called_once_with(4)
            mocked_stage.assert_called_once_with(add="/path", message=message)
开发者ID:AlexSnet,项目名称:gitfs,代码行数:24,代码来源:test_current.py


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