Exemplo n.º 1
0
    def test_getattr_for_a_valid_file(self):
        mocked_repo = MagicMock()
        mocked_commit = MagicMock()

        mocked_commit.tree = "tree"
        mocked_commit.commit_time = "now+1"
        mocked_repo.revparse_single.return_value = mocked_commit
        mocked_repo.get_git_object_default_stats.return_value = {
            'st_mode': S_IFREG | 0o444,
            'st_size': 10
        }

        view = CommitView(repo=mocked_repo, commit_sha1="sha1",
                          mount_time="now", uid=1, gid=1)

        result = view.getattr("/path", 1)

        asserted_result = {
            'st_uid': 1,
            'st_gid': 1,
            'st_mtime': "now+1",
            'st_ctime': "now+1",
            'st_mode': S_IFREG | 0o444,
            'st_size': 10
        }
        assert result == asserted_result
        args = ("tree", "/path")
        mocked_repo.get_git_object_default_stats.assert_called_once_with(*args)
Exemplo n.º 2
0
    def test_getattr_with_simple_path(self):
        mocked_repo = MagicMock()
        mocked_commit = MagicMock()
        stats = {
            'st_mode': S_IFDIR | 0o555,
            'st_nlink': 2
        }

        mocked_commit.tree = "tree"
        mocked_commit.commit_time = "now+1"
        mocked_repo.revparse_single.return_value = mocked_commit
        mocked_repo.get_git_object_default_stats.return_value = stats

        view = CommitView(repo=mocked_repo, commit_sha1="sha1",
                          mount_time="now", uid=1, gid=1)
        result = view.getattr("/", 1)
        asserted_result = {
            'st_uid': 1,
            'st_gid': 1,
            'st_mtime': "now+1",
            'st_ctime': "now+1",
            'st_mode': S_IFDIR | 0o555,
            'st_nlink': 2
        }
        assert result == asserted_result
Exemplo n.º 3
0
    def test_getattr_for_a_valid_file(self):
        mocked_repo = MagicMock()
        mocked_commit = MagicMock()

        mocked_commit.tree = "tree"
        mocked_commit.commit_time = "now+1"
        mocked_repo.revparse_single.return_value = mocked_commit
        mocked_repo.get_git_object_default_stats.return_value = {
            'st_mode': S_IFREG | 0o444,
            'st_size': 10
        }

        view = CommitView(repo=mocked_repo,
                          commit_sha1="sha1",
                          mount_time="now",
                          uid=1,
                          gid=1)

        result = view.getattr("/path", 1)

        asserted_result = {
            'st_uid': 1,
            'st_gid': 1,
            'st_mtime': "now+1",
            'st_ctime': "now+1",
            'st_mode': S_IFREG | 0o444,
            'st_size': 10
        }
        assert result == asserted_result
        args = ("tree", "/path")
        mocked_repo.get_git_object_default_stats.assert_called_once_with(*args)
Exemplo n.º 4
0
    def test_getattr_with_simple_path(self):
        mocked_repo = MagicMock()
        mocked_commit = MagicMock()
        stats = {'st_mode': S_IFDIR | 0o555, 'st_nlink': 2}

        mocked_commit.tree = "tree"
        mocked_commit.commit_time = "now+1"
        mocked_repo.revparse_single.return_value = mocked_commit
        mocked_repo.get_git_object_default_stats.return_value = stats

        view = CommitView(repo=mocked_repo,
                          commit_sha1="sha1",
                          mount_time="now",
                          uid=1,
                          gid=1)
        result = view.getattr("/", 1)
        asserted_result = {
            'st_uid': 1,
            'st_gid': 1,
            'st_mtime': "now+1",
            'st_ctime': "now+1",
            'st_mode': S_IFDIR | 0o555,
            'st_nlink': 2
        }
        assert result == asserted_result
Exemplo n.º 5
0
    def test_getattr_with_invalid_object_type(self):
        mocked_repo = MagicMock()
        mocked_commit = MagicMock()

        mocked_commit.tree = "tree"
        mocked_commit.commit_time = "now+1"
        mocked_repo.revparse_single.return_value = mocked_commit
        mocked_repo.get_git_object_default_stats.return_value = None

        view = CommitView(repo=mocked_repo, commit_sha1="sha1",
                          mount_time="now", uid=1, gid=1)

        with pytest.raises(FuseOSError):
            view.getattr("/path", 1)

        args = ("tree", "/path")
        mocked_repo.get_git_object_default_stats.assert_called_once_with(*args)
Exemplo n.º 6
0
    def test_getattr_with_invalid_object_type(self):
        mocked_repo = MagicMock()
        mocked_commit = MagicMock()

        mocked_commit.tree = "tree"
        mocked_commit.commit_time = "now+1"
        mocked_repo.revparse_single.return_value = mocked_commit
        mocked_repo.get_git_object_default_stats.return_value = None

        view = CommitView(repo=mocked_repo, commit_sha1="sha1",
                          mount_time="now", uid=1, gid=1)

        with pytest.raises(FuseOSError):
            view.getattr("/path", 1)

        args = ("tree", "/path")
        mocked_repo.get_git_object_default_stats.assert_called_once_with(*args)
Exemplo n.º 7
0
    def test_getattr_with_no_path(self):
        mocked_repo = MagicMock()
        mocked_commit = MagicMock()

        mocked_commit.tree = "tree"
        mocked_repo.revparse_single.return_value = mocked_commit

        view = CommitView(repo=mocked_repo, commit_sha1="sha1")
        assert view.getattr(False, 1) is None
Exemplo n.º 8
0
    def test_getattr_with_no_path(self):
        mocked_repo = MagicMock()
        mocked_commit = MagicMock()

        mocked_commit.tree = "tree"
        mocked_repo.revparse_single.return_value = mocked_commit

        view = CommitView(repo=mocked_repo, commit_sha1="sha1")
        assert view.getattr(False, 1) is None