Skip to content

Commit 21d4a0a

Browse files
committed
Fixed query builder
1 parent 5e1d026 commit 21d4a0a

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

src/superannotate/lib/core/conditions.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def __or__(self, other):
3434

3535
self._condition_set.append(
3636
QueryCondition(
37-
CONDITION_OR, other.build_query(), {other._key: other._value}
37+
CONDITION_OR,
38+
other.build_query(),
39+
{other._key: other._value} if isinstance(other, Condition) else {},
3840
)
3941
)
4042
return self
@@ -52,7 +54,9 @@ def __and__(self, other):
5254

5355
self._condition_set.append(
5456
QueryCondition(
55-
CONDITION_AND, other.build_query(), {} if isinstance(other, Condition) else {other._key: other._value}
57+
CONDITION_AND,
58+
other.build_query(),
59+
{other._key: other._value} if isinstance(other, Condition) else {},
5660
)
5761
)
5862
return self

tests/integration/folders/test_folders.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def test_search_folders(self):
4646
folders = sa.search_folders(self.PROJECT_NAME)
4747
assert all(["is_root" not in folder for folder in folders])
4848

49-
5049
def test_basic_folders(self):
5150
sa.upload_images_from_folder_to_project(
5251
self.PROJECT_NAME, self.folder_path, annotation_status="InProgress"
@@ -265,3 +264,10 @@ def test_create_long_name(self):
265264
'A while back I needed to count the amount of letters that '
266265
'a piece of text in an email template had (to avoid passing any)'
267266
)
267+
268+
def test_search_folder(self):
269+
sa.create_folder(self.PROJECT_NAME, self.TEST_FOLDER_NAME_1)
270+
sa.create_folder(self.PROJECT_NAME, self.TEST_FOLDER_NAME_2)
271+
folders = sa.search_folders(self.PROJECT_NAME, self.TEST_FOLDER_NAME_1)
272+
assert len(folders) == 1
273+
assert folders[0] == self.TEST_FOLDER_NAME_1

tests/integration/projects/test_basic_project.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
import pytest
77

88
from src.superannotate import SAClient
9-
sa = SAClient()
109
from tests import DATA_SET_PATH
1110
from tests.integration.base import BaseTestCase
1211

12+
sa = SAClient()
13+
1314

14-
class TestWorkflowGet(BaseTestCase):
15+
class TestProjectBasic(BaseTestCase):
1516
PROJECT_NAME = "TestWorkflowGet"
1617
PROJECT_TYPE = "Vector"
1718
PROJECT_DESCRIPTION = "DESCRIPTION"
@@ -101,6 +102,12 @@ def test_workflow_get(self):
101102
self.assertEqual(workflows[0]['className'], "class1")
102103
self.assertEqual(workflows[1]['className'], "class2")
103104

105+
def test_include_complete_image_count(self):
106+
self._attach_items() # will attach 4 items
107+
sa.set_annotation_statuses(self.PROJECT_NAME, annotation_status="Completed")
108+
metadata = sa.get_project_metadata(self.PROJECT_NAME, include_complete_image_count=True)
109+
assert metadata["completed_images_count"] == 4
110+
104111

105112
class TestProject(BaseTestCase):
106113
PROJECT_NAME = "sample_basic_project"

0 commit comments

Comments
 (0)