def test_chmod_in_git_dir(self): current = CurrentView(repo="repo", uid=1, gid=1, repo_path="repo_path", ignore=CachedIgnore()) with pytest.raises(FuseOSError): current.chmod(".git/", "mode")
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", 0o100644, ) == "done" message = 'Chmod to 0%o on %s' % (0o644, "/path") mocked_index.assert_called_once_with(add="/path", message=message) current_view.PassthroughView.chmod = old_chmod
def test_chmod_on_dir(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_full = MagicMock(return_value="repo/path/to/dir") mocked_repo = MagicMock(_full_path=mocked_full) with patch('gitfs.views.current.os') as mocked_os: mocked_os.path.isdir.return_value = True current = CurrentView(repo=mocked_repo, uid=1, gid=1, repo_path="repo_path", ignore=CachedIgnore()) assert current.chmod("/path/to/dir", 0040755) == "done" mocked_os.path.isdir.assert_called_once_with('repo/path/to/dir') current_view.PassthroughView.chmod = old_chmod
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
def test_chmod_on_dir(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_full = MagicMock(return_value="repo/path/to/dir") mocked_repo = MagicMock(_full_path=mocked_full) with patch('gitfs.views.current.os') as mocked_os: mocked_os.path.isdir.return_value = True current = CurrentView(repo=mocked_repo, uid=1, gid=1, repo_path="repo_path", ignore=CachedIgnore()) assert current.chmod( "/path/to/dir", 0o040755, ) == "done" mocked_os.path.isdir.assert_called_once_with('repo/path/to/dir') current_view.PassthroughView.chmod = old_chmod