Beispiel #1
0
    def test_write_to_large_file(self):
        current = CurrentView(repo="repo",
                              uid=1,
                              gid=1,
                              repo_path="repo_path",
                              read_only=Event(),
                              ignore=CachedIgnore())
        current.max_size = 10
        current.dirty = {'/path': {'size': 5}}

        with pytest.raises(FuseOSError):
            current.write("/path", "bufffffert", 11, 1)
Beispiel #2
0
    def test_write_to_large_file(self):
        current = CurrentView(repo="repo", uid=1, gid=1,
                              repo_path="repo_path",
                              read_only=Event(), ignore=CachedIgnore())
        current.max_size = 10
        current.dirty = {
            '/path': {
                'size': 5
            }
        }

        with pytest.raises(FuseOSError):
            current.write("/path", "bufffffert", 11, 1)
Beispiel #3
0
    def test_release_without_stage(self):
        message = "No 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, 'stage': False}}

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

            mocked_os.close.assert_called_once_with(4)
            assert mocked_stage.call_count == 0
Beispiel #4
0
    def test_create(self):
        from gitfs.views import current as current_view
        old_chmod = current_view.PassthroughView.chmod
        mock_chmod = lambda self, path, mode: "done"
        current_view.PassthroughView.chmod = mock_chmod

        mocked_open = MagicMock()
        mocked_open.return_value = "done"
        current = CurrentView(repo="repo",
                              uid=1,
                              gid=1,
                              repo_path="repo_path",
                              ignore=CachedIgnore())
        current.dirty = {'/path': {'content': "here"}}
        current.open_for_write = mocked_open

        assert current.create("/path", "mode") == "done"
        current_view.PassthroughView.chmod = old_chmod
Beispiel #5
0
    def test_release_with_stage(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, "stage": True}}

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

            mocked_os.close.assert_called_once_with(4)
            mocked_stage.assert_called_once_with(add="/path", message=message)
Beispiel #6
0
    def test_write(self):
        from gitfs.views import current as current_view
        mocked_write = lambda self, path, buf, offste, fh: "done"
        old_write = current_view.PassthroughView.write
        current_view.PassthroughView.write = mocked_write

        current = CurrentView(repo="repo",
                              uid=1,
                              gid=1,
                              repo_path="repo_path",
                              read_only=Event(),
                              ignore=CachedIgnore())
        current.max_offset = 20
        current.max_size = 20
        current.dirty = {1: {}}

        assert current.write("/path", "buf", 3, 1) == "done"
        assert current.dirty == {1: {'message': 'Update /path', 'stage': True}}
        current_view.PassthroughView.write = old_write
Beispiel #7
0
    def test_create(self):
        from gitfs.views import current as current_view
        old_chmod = current_view.PassthroughView.chmod
        mock_chmod = lambda self, path, mode: "done"
        current_view.PassthroughView.chmod = mock_chmod

        mocked_open = MagicMock()
        mocked_open.return_value = "done"
        current = CurrentView(repo="repo", uid=1, gid=1,
                              repo_path="repo_path",
                              ignore=CachedIgnore())
        current.dirty = {
            '/path': {
                'content': "here"
            }
        }
        current.open_for_write = mocked_open

        assert current.create("/path", "mode") == "done"
        current_view.PassthroughView.chmod = old_chmod
Beispiel #8
0
    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)
Beispiel #9
0
    def test_write(self):
        from gitfs.views import current as current_view
        mocked_write = lambda self, path, buf, offste, fh: "done"
        old_write = current_view.PassthroughView.write
        current_view.PassthroughView.write = mocked_write

        current = CurrentView(repo="repo", uid=1, gid=1,
                              repo_path="repo_path",
                              read_only=Event(), ignore=CachedIgnore())
        current.max_offset = 20
        current.max_size = 20
        current.dirty = {
            1: {}
        }

        assert current.write("/path", "buf", 3, 1) == "done"
        assert current.dirty == {
            1: {
                'message': 'Update /path',
            }
        }
        current_view.PassthroughView.write = old_write