Exemplo n.º 1
0
    def test_readdir(self):
        mocked_os = MagicMock()
        mocked_os.path.join = os.path.join
        mocked_os.path.is_dir.return_value = True
        mocked_os.listdir.return_value = ['one_dir', 'one_file', '.git']

        with patch.multiple('gitfs.views.passthrough', os=mocked_os):
            view = PassthroughView(repo=self.repo, repo_path=self.repo_path)
            result = view.readdir("/magic/path", 0)
            dirents = [directory for directory in result]

            assert dirents == ['.', '..', 'one_dir', 'one_file']
            path = '/the/root/path/magic/path'
            mocked_os.path.isdir.assert_called_once_with(path)
            mocked_os.listdir.assert_called_once_with(path)
Exemplo n.º 2
0
    def test_readdir(self):
        mocked_os = MagicMock()
        mocked_os.path.join = os.path.join
        mocked_os.path.is_dir.return_value = True
        mocked_os.listdir.return_value = ['one_dir', 'one_file', '.git']

        with patch.multiple('gitfs.views.passthrough', os=mocked_os):
            view = PassthroughView(repo=self.repo, repo_path=self.repo_path)
            result = view.readdir("/magic/path", 0)
            dirents = [directory for directory in result]

            assert dirents == ['.', '..', 'one_dir', 'one_file']
            path = '/the/root/path/magic/path'
            mocked_os.path.isdir.assert_called_once_with(path)
            mocked_os.listdir.assert_called_once_with(path)
Exemplo n.º 3
0
    def test_readdir(self):
        mocked_os = MagicMock()
        mocked_os.path.join = os.path.join
        mocked_os.path.is_dir.return_value = True
        mocked_os.listdir.return_value = ["one_dir", "one_file", ".git"]

        with patch.multiple("gitfs.views.passthrough", os=mocked_os):
            view = PassthroughView(repo=self.repo, repo_path=self.repo_path)
            result = view.readdir("/magic/path", 0)
            dirents = [directory for directory in result]

            assert dirents == [".", "..", "one_dir", "one_file"]
            path = "/the/root/path/magic/path"
            mocked_os.path.isdir.assert_called_once_with(path)
            mocked_os.listdir.assert_called_once_with(path)