Skip to content

Commit bc1c620

Browse files
authored
Merge pull request #690 from superannotateai/fix_search_folders
fix search_folders
2 parents fba2fc0 + 5bacedf commit bc1c620

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,11 @@ def search_folders(
627627
if return_metadata:
628628
condition &= Condition("includeUsers", return_metadata, EQ)
629629
if status:
630-
condition &= Condition(
631-
"status", constants.FolderStatus.get_value(status), EQ
632-
)
630+
if isinstance(status, list):
631+
status_condition = [constants.FolderStatus.get_value(i) for i in status]
632+
else:
633+
status_condition = constants.FolderStatus.get_value(status)
634+
condition &= Condition("status", status_condition, EQ)
633635
response = self.controller.folders.list(project, condition)
634636
if response.errors:
635637
raise AppException(response.errors)

tests/integration/folders/test_search_folders.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class TestSearchFolders(BaseTestCase):
1313
SPECIAL_CHARS = r"/\:*?“<>|"
1414
TEST_FOLDER_NAME_1 = "folder_1"
1515
TEST_FOLDER_NAME_2 = "folder_2"
16+
TEST_FOLDER_NAME_3 = "folder_3"
1617

1718
def test_search_folders(self):
1819
sa.create_folder(self.PROJECT_NAME, self.TEST_FOLDER_NAME_1)
@@ -29,6 +30,26 @@ def test_search_folders(self):
2930
folders = sa.search_folders(self.PROJECT_NAME, status="NotStarted")
3031
assert len(folders) == 2
3132

33+
# with status list
34+
sa.create_folder(self.PROJECT_NAME, self.TEST_FOLDER_NAME_3)
35+
sa.set_folder_status(
36+
self.PROJECT_NAME, self.TEST_FOLDER_NAME_3, status="InProgress"
37+
)
38+
folders_2 = sa.search_folders(
39+
self.PROJECT_NAME, status=["NotStarted", "InProgress", "Completed"]
40+
)
41+
assert len(folders_2) == 3
42+
43+
folders_3 = sa.search_folders(
44+
self.PROJECT_NAME, status=["InProgress", "Completed"]
45+
)
46+
assert len(folders_3) == 1
47+
48+
folders_4 = sa.search_folders(
49+
self.PROJECT_NAME, status=["NotStarted", "Completed"]
50+
)
51+
assert len(folders_4) == 2
52+
3253
# with invalid status
3354
pattern = (
3455
r"(\s+)status(\s+)Available values are 'NotStarted', "

0 commit comments

Comments
 (0)