mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-10-10 04:30:55 +08:00
#50 fixed bug in listing subdirs
This commit is contained in:
@@ -51,7 +51,7 @@ class FileItemSource(ItemSource):
|
|||||||
return self.convert_h5ad_path_to_annotation(item.descriptor)
|
return self.convert_h5ad_path_to_annotation(item.descriptor)
|
||||||
|
|
||||||
def list_items(self, filter: str = None) -> ItemTree:
|
def list_items(self, filter: str = None) -> ItemTree:
|
||||||
item_tree = self.scan_directory()
|
item_tree = self.scan_directory("" if filter is None else filter)
|
||||||
|
|
||||||
"""def get_items(dir):
|
"""def get_items(dir):
|
||||||
if dir.branches:
|
if dir.branches:
|
||||||
|
|||||||
@@ -5,20 +5,23 @@ from unittest.mock import patch
|
|||||||
from cellxgene_gateway.items.file.fileitem_source import FileItemSource
|
from cellxgene_gateway.items.file.fileitem_source import FileItemSource
|
||||||
|
|
||||||
|
|
||||||
|
def stub_join(path):
|
||||||
|
path.join = lambda x, y: x + "/" + y
|
||||||
|
|
||||||
|
|
||||||
class TestFileItemSource(unittest.TestCase):
|
class TestFileItemSource(unittest.TestCase):
|
||||||
@patch("os.path")
|
@patch("os.path")
|
||||||
@patch("os.listdir")
|
@patch("os.listdir")
|
||||||
def test_list_items_GIVEN_no_subpath_THEN_checks_dir(self, listdir, path):
|
def test_list_items_GIVEN_no_subpath_THEN_checks_dir(self, listdir, path):
|
||||||
path.join = lambda x, y: x + "/" + y
|
stub_join(path)
|
||||||
source = FileItemSource("/tmp/unittest", "local")
|
source = FileItemSource("/tmp/unittest", "local")
|
||||||
source.list_items()
|
source.list_items()
|
||||||
path.exists.assert_called_once_with("/tmp/unittest/")
|
path.exists.assert_called_once_with("/tmp/unittest/")
|
||||||
|
|
||||||
@patch("os.path")
|
@patch("os.path")
|
||||||
@patch("os.listdir")
|
@patch("os.listdir")
|
||||||
@unittest.skip("fail for #50")
|
|
||||||
def test_list_items_GIVEN_subpath_THEN_checks_subpath(self, listdir, path):
|
def test_list_items_GIVEN_subpath_THEN_checks_subpath(self, listdir, path):
|
||||||
path.join = lambda x, y: x + "/" + y
|
stub_join(path)
|
||||||
source = FileItemSource("/tmp/unittest", "local")
|
source = FileItemSource("/tmp/unittest", "local")
|
||||||
source.list_items("foo")
|
source.list_items("foo")
|
||||||
path.exists.assert_called_once_with("/tmp/unittest/foo")
|
path.exists.assert_called_once_with("/tmp/unittest/foo")
|
||||||
|
|||||||
Reference in New Issue
Block a user