Fix querying by task parent

This commit is contained in:
allegroai 2021-05-03 16:55:03 +03:00
parent 6434f1028e
commit 47184c2833
2 changed files with 12 additions and 2 deletions

View File

@ -271,7 +271,8 @@ class GetMixin(PropsMixin):
- AND can be achieved using a preceding "__$all" or "__$and" value (operator) - AND can be achieved using a preceding "__$all" or "__$and" value (operator)
""" """
if not isinstance(data, (list, tuple)): if not isinstance(data, (list, tuple)):
raise MakeGetAllQueryError("expected list", field) data = [data]
# raise MakeGetAllQueryError("expected list", field)
# TODO: backwards compatibility only for older API versions # TODO: backwards compatibility only for older API versions
helper = cls.ListFieldBucketHelper(legacy=True) helper = cls.ListFieldBucketHelper(legacy=True)

View File

@ -5,6 +5,15 @@ class TestTaskParent(TestService):
def setUp(self, version="2.12"): def setUp(self, version="2.12"):
super().setUp(version=version) super().setUp(version=version)
def test_query_by_parents(self):
parent = self.new_task()
child = self.new_task(name="Test parent task1", parent=parent)
tasks = self.api.tasks.get_all_ex(parent=[parent]).tasks
self.assertEqual([t.id for t in tasks], [child])
tasks = self.api.tasks.get_all(parent=parent).tasks
self.assertEqual([t.id for t in tasks], [child])
def test_query_by_project(self): def test_query_by_project(self):
# stand alone task # stand alone task
parent_sa_name = "Test parent parent standalone" parent_sa_name = "Test parent parent standalone"
@ -74,6 +83,6 @@ class TestTaskParent(TestService):
def new_task(self, **kwargs): def new_task(self, **kwargs):
self.update_missing( self.update_missing(
kwargs, type="testing", name="test project tags", input=dict(view=dict()) kwargs, type="testing", name="test task parents", input=dict(view=dict())
) )
return self.create_temp("tasks", **kwargs) return self.create_temp("tasks", **kwargs)