Skip to content

Commit

Permalink
[filebrowser] Add test for default index dir for empty path in URL (#…
Browse files Browse the repository at this point in the history
…2665)

- For commit: c5a44c6
  • Loading branch information
Harshg999 committed Dec 22, 2021
1 parent c5a44c6 commit 28e2d38
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/filebrowser/src/filebrowser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def download(request, path):

def view(request, path):
"""Dispatches viewing of a path to either index() or fileview(), depending on type."""

# index directory have to be default.
if not path:
path = '/'
Expand Down
15 changes: 15 additions & 0 deletions apps/filebrowser/src/filebrowser/views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
from aws.s3.s3test_utils import get_test_bucket

from azure.conf import is_abfs_enabled, is_adls_enabled, ABFS_CLUSTERS

from django.urls import reverse
from django.utils.encoding import smart_str
from django.http import HttpResponse

from nose.plugins.attrib import attr
from nose.plugins.skip import SkipTest
from nose.tools import assert_true, assert_false, assert_equal, assert_not_equal, assert_raises,\
Expand All @@ -51,6 +54,7 @@
from desktop.lib.test_utils import grant_access, add_to_group, add_permission, remove_from_group
from desktop.lib.view_util import location_to_url
from desktop.conf import is_oozie_enabled, RAZ

from hadoop import pseudo_hdfs4
from hadoop.conf import UPLOAD_CHUNK_SIZE
from hadoop.fs.webhdfs import WebHdfs
Expand Down Expand Up @@ -1627,3 +1631,14 @@ def test_hdfs_redirect(self):
finally:
for reset in resets:
reset()

def test_empty_path_to_default_index_dir(self):
with patch('filebrowser.views._normalize_path') as _normalize_path:
with patch('desktop.lib.fs.proxyfs.ProxyFS.stats') as stats:
with patch('filebrowser.views.listdir_paged') as listdir_paged:
stats.isDir.return_value = True
listdir_paged.return_value = HttpResponse()

response = self.client.get('/filebrowser/view=')

_normalize_path.assert_called_with('/')

0 comments on commit 28e2d38

Please sign in to comment.