Exemplo n.º 1
0
    def test_stage(self):
        mocked_repo = MagicMock()
        mocked_sanitize = MagicMock()
        mocked_queue = MagicMock()
        mocked_files = MagicMock(return_value=None)

        mocked_sanitize.return_value = ["to-stage"]

        current = CurrentView(
            repo=mocked_repo,
            repo_path="repo_path",
            queue=mocked_queue,
            ignore=CachedIgnore(),
        )
        current._sanitize = mocked_sanitize
        current._get_files_from_path = mocked_files
        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_files.has_calls([call(["add"])])
        mocked_sanitize.has_calls([call(["add"]), call(["remove"])])
Exemplo n.º 2
0
    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'])])
Exemplo n.º 3
0
 def test_sanitize(self):
     current = CurrentView(repo="repo", repo_path="repo_path")
     assert current._sanitize("/path") == "path"
Exemplo n.º 4
0
 def test_sanitize(self):
     current = CurrentView(repo="repo", repo_path="repo_path")
     assert current._sanitize("/path") == "path"