From 381d40d2a7ae5c35cb687f91b6cbc680bcc8c6ed Mon Sep 17 00:00:00 2001 From: jrybicki-jsc <j.rybicki@fz-juelich.de> Date: Fri, 28 May 2021 12:19:06 +0200 Subject: [PATCH] getList should return list --- apiserver/storage/JsonFileStorageAdapter.py | 4 ++-- tests/storage_tests/test_jsonbackend.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apiserver/storage/JsonFileStorageAdapter.py b/apiserver/storage/JsonFileStorageAdapter.py index e8fbc6f..86a9972 100644 --- a/apiserver/storage/JsonFileStorageAdapter.py +++ b/apiserver/storage/JsonFileStorageAdapter.py @@ -29,12 +29,12 @@ class JsonFileStorageAdapter(AbstractLocationDataStorageAdapter): if not (os.path.exists(self.data_dir) and os.path.isdir(self.data_dir)): raise Exception('Data Directory \"' + self.data_dir + '\" does not exist.') - def getList(self, type: LocationDataType): + def getList(self, type: LocationDataType) -> List: localpath = os.path.join(self.data_dir, type.value) if not (os.path.isdir(localpath)): # This type has apparently not yet been used at all, create its directory and return an empty json file os.mkdir(localpath) - return {} + return [] else: allFiles = [f for f in os.listdir(localpath) if os.path.isfile(os.path.join(localpath, f))] # now each file has to be checked for its filename (= id) and the LocationData name (which is inside the json) diff --git a/tests/storage_tests/test_jsonbackend.py b/tests/storage_tests/test_jsonbackend.py index 122a11e..01369bf 100644 --- a/tests/storage_tests/test_jsonbackend.py +++ b/tests/storage_tests/test_jsonbackend.py @@ -25,5 +25,5 @@ class SomeTests(unittest.TestCase): def test_getList(self): test_type = LocationDataType.DATASET lst = self.store.getList(type=test_type) - self.assertEqual(lst, {}, 'Id should not be none') + self.assertEqual(lst, [], 'Id should not be none') \ No newline at end of file -- GitLab