def transform_to_conj_expr( expr: ConjunctionExpression, ) -> Tuple[_core_cond.ConjunctionExpression, typing.List[Promise]]: left, left_promises = transform_to_boolexpr(expr.lhs) right, right_promises = transform_to_boolexpr(expr.rhs) return ( _core_cond.ConjunctionExpression(left_expression=left, right_expression=right, operator=_logical_ops[expr.op],), merge_promises(*left_promises, *right_promises), )
def test_branch_node(): nm = _get_sample_node_metadata() task = _workflow.TaskNode(reference_id=_generic_id) bd = _literals.BindingData(scalar=_literals.Scalar( primitive=_literals.Primitive(integer=5))) bd2 = _literals.BindingData(scalar=_literals.Scalar( primitive=_literals.Primitive(integer=99))) binding = _literals.Binding(var='myvar', binding=bd) binding2 = _literals.Binding(var='myothervar', binding=bd2) obj = _workflow.Node(id='some:node:id', metadata=nm, inputs=[binding, binding2], upstream_node_ids=[], output_aliases=[], task_node=task) bn = _workflow.BranchNode( _workflow.IfElseBlock( case=_workflow.IfBlock(condition=_condition.BooleanExpression( comparison=_condition.ComparisonExpression( _condition.ComparisonExpression.Operator.EQ, _condition.Operand(primitive=_literals.Primitive( integer=5)), _condition.Operand(primitive=_literals.Primitive( integer=2)))), then_node=obj), other=[ _workflow.IfBlock(condition=_condition.BooleanExpression( conjunction=_condition.ConjunctionExpression( _condition.ConjunctionExpression.LogicalOperator.AND, _condition.BooleanExpression( comparison=_condition.ComparisonExpression( _condition.ComparisonExpression.Operator.EQ, _condition.Operand( primitive=_literals.Primitive(integer=5)), _condition.Operand( primitive=_literals.Primitive( integer=2)))), _condition.BooleanExpression( comparison=_condition.ComparisonExpression( _condition.ComparisonExpression.Operator.EQ, _condition.Operand( primitive=_literals.Primitive(integer=5)), _condition.Operand( primitive=_literals.Primitive( integer=2)))))), then_node=obj) ], else_node=obj))