From 0375a717c9c6a7f32221970953beb40066fdb602 Mon Sep 17 00:00:00 2001 From: Alok Saldanha Date: Sun, 18 Jul 2021 08:54:30 -0400 Subject: [PATCH] #50 fixed bug in listing subdirs --- cellxgene_gateway/items/file/fileitem_source.py | 2 +- tests/items/file/test_fileitem_source.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cellxgene_gateway/items/file/fileitem_source.py b/cellxgene_gateway/items/file/fileitem_source.py index 5a23048..4d236bc 100644 --- a/cellxgene_gateway/items/file/fileitem_source.py +++ b/cellxgene_gateway/items/file/fileitem_source.py @@ -51,7 +51,7 @@ class FileItemSource(ItemSource): return self.convert_h5ad_path_to_annotation(item.descriptor) 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): if dir.branches: diff --git a/tests/items/file/test_fileitem_source.py b/tests/items/file/test_fileitem_source.py index b9448d1..782fcad 100644 --- a/tests/items/file/test_fileitem_source.py +++ b/tests/items/file/test_fileitem_source.py @@ -5,20 +5,23 @@ from unittest.mock import patch from cellxgene_gateway.items.file.fileitem_source import FileItemSource +def stub_join(path): + path.join = lambda x, y: x + "/" + y + + class TestFileItemSource(unittest.TestCase): @patch("os.path") @patch("os.listdir") 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.list_items() path.exists.assert_called_once_with("/tmp/unittest/") @patch("os.path") @patch("os.listdir") - @unittest.skip("fail for #50") 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.list_items("foo") path.exists.assert_called_once_with("/tmp/unittest/foo")