def test_task_queryset_cource_for_query(self): queryset = managers.TaskQuerySet(model=Task).coerce_for([ChildFlow]) self.assertEqual(queryset.query.select_related, { 'childtask': {}, 'process': {} }) """
def test_task_queryset_cource_values_list(self): process = ChildProcess.objects.create(flow_class=ChildFlow) task = ChildTask.objects.create(process=process, flow_task=ChildFlow.start) queryset = managers.TaskQuerySet(model=Task).coerce_for( [ChildFlow]).values_list('id') self.assertEqual([(task.pk, )], list(queryset))
def _test_task_queryset_coerce_classes(self): process1 = ChildProcess.objects.create(flow_cls=ChildFlow) process2 = GrandChildProcess.objects.create(flow_cls=GrandChildFlow) task1 = ChildTask.objects.create(process=process1, flow_task=ChildFlow.start) task2 = Task.objects.create(process=process2, flow_task=GrandChildFlow.start) with self.assertNumQueries(1): queryset = managers.TaskQuerySet(model=Task).coerce_for([GrandChildFlow, ChildFlow]) self.assertEqual(set(queryset), set([task1, task2]))
def test_task_queryset_filter_by_flowcls_succeed(self): queryset = managers.TaskQuerySet(model=Task).filter( flow_task=ChildFlow.start) self.assertEqual( str(queryset.query).strip(), 'SELECT "viewflow_task"."id", "viewflow_task"."flow_task", "viewflow_task"."flow_task_type",' ' "viewflow_task"."status", "viewflow_task"."created", "viewflow_task"."assigned", "viewflow_task"."started",' ' "viewflow_task"."finished", "viewflow_task"."token", "viewflow_task"."process_id",' ' "viewflow_task"."owner_id", "viewflow_task"."external_task_id",' ' "viewflow_task"."owner_permission", "viewflow_task"."comments" FROM "viewflow_task"' ' WHERE "viewflow_task"."flow_task" = tests/test_managers.ChildFlow.start' ' ORDER BY "viewflow_task"."created" DESC')