Beispiel #1
0
    def test_getattr(self):
        mocked_full = MagicMock()
        mocked_os = MagicMock()
        mocked_stat = MagicMock()
        mocked_repo = MagicMock()

        mocked_stat.simple = "stat"
        mocked_os.lstat.return_value = mocked_stat
        mocked_full.return_value = "full_path"
        mocked_repo._full_path = mocked_full

        with patch.multiple('gitfs.views.current', os=mocked_os,
                            STATS=['simple']):
            current = CurrentView(repo=mocked_repo, uid=1, gid=1,
                                  repo_path="repo_path",
                                  ignore=CachedIgnore())
            current._full_path = mocked_full

            result = current.getattr("path")
            asserted_result = {
                'st_uid': 1,
                'st_gid': 1,
                'simple': "stat"
            }
            assert result == asserted_result

            mocked_os.lstat.assert_called_once_with("full_path")
            mocked_full.assert_called_once_with("path")
Beispiel #2
0
    def test_getattr(self):
        mocked_full = MagicMock()
        mocked_os = MagicMock()
        mocked_stat = MagicMock()
        mocked_repo = MagicMock()

        mocked_stat.simple = "stat"
        mocked_os.lstat.return_value = mocked_stat
        mocked_full.return_value = "full_path"
        mocked_repo._full_path = mocked_full

        with patch.multiple('gitfs.views.current',
                            os=mocked_os,
                            STATS=['simple']):
            current = CurrentView(repo=mocked_repo,
                                  uid=1,
                                  gid=1,
                                  repo_path="repo_path",
                                  ignore=CachedIgnore())
            current._full_path = mocked_full

            result = current.getattr("path")
            asserted_result = {'st_uid': 1, 'st_gid': 1, 'simple': "stat"}
            assert result == asserted_result

            mocked_os.lstat.assert_called_once_with("full_path")
            mocked_full.assert_called_once_with("path")
Beispiel #3
0
    def test_readlink(self):
        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.readlink.return_value = "done"

            current = CurrentView(repo=mocked_repo, repo_path="repo_path",
                                  ignore=CachedIgnore())
            current._full_path = mocked_full_path

            assert current.readlink("path") == "done"
Beispiel #4
0
    def test_readlink(self):
        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.readlink.return_value = "done"

            current = CurrentView(repo=mocked_repo, repo_path="repo_path",
                                  ignore=CachedIgnore())
            current._full_path = mocked_full_path

            assert current.readlink("path") == "done"
Beispiel #5
0
    def test_open(self):
        mocked_full = MagicMock(return_value="full_path")
        mocked_repo = MagicMock(_full_path=mocked_full)
        mocked_os = MagicMock()

        mocked_os.open.return_value = 1

        with patch.multiple('gitfs.views.current', os=mocked_os):
            current = CurrentView(repo=mocked_repo,
                                  repo_path="repo_path",
                                  ignore=CachedIgnore())

            current._full_path = mocked_full
            current.writing = set([])

            assert current.open("path/", os.O_WRONLY) == 1
            mocked_os.open.assert_called_once_with("full_path", os.O_WRONLY)
Beispiel #6
0
    def test_open(self):
        mocked_full = MagicMock(return_value="full_path")
        mocked_repo = MagicMock(_full_path=mocked_full)
        mocked_os = MagicMock()

        mocked_os.open.return_value = 1

        with patch.multiple('gitfs.views.current', os=mocked_os):
            current = CurrentView(repo=mocked_repo,
                                  repo_path="repo_path",
                                  ignore=CachedIgnore())

            current._full_path = mocked_full
            current.writing = set([])

            assert current.open("path/", os.O_WRONLY) == 1
            mocked_os.open.assert_called_once_with("full_path", os.O_WRONLY)