@ -396,44 +396,49 @@ def test_dependent_get_define(mock_condition_code_version, mock_task_code_versio
def test_condition_set_dep_workflow ( mock_task_code_version ) :
def test_condition_set_dep_workflow ( mock_task_code_version ) :
""" Test task condition set dependence in workflow level. """
""" Test task condition set dependence in workflow level. """
with ProcessDefinition ( name = " test-condition-set-dep-workflow " ) as pd :
with ProcessDefinition ( name = " test-condition-set-dep-workflow " ) as pd :
parent = Task ( name = " parent " , task_type = TEST_TYPE )
condition_pre_task_1 = Task ( name = " pre_task_success_1 " , task_type = TEST_TYPE )
condition_success_1 = Task ( name = " condition_success_1 " , task_type = TEST_TYPE )
condition_pre_task_2 = Task ( name = " pre_task_success_2 " , task_type = TEST_TYPE )
condition_success_2 = Task ( name = " condition_success_2 " , task_type = TEST_TYPE )
condition_pre_task_3 = Task ( name = " pre_task_fail " , task_type = TEST_TYPE )
condition_fail = Task ( name = " condition_fail " , task_type = TEST_TYPE )
cond_operator = And (
cond_operator = And (
And (
And (
SUCCESS ( condition_success_1 , condition_success _2 ) ,
SUCCESS ( condition_pre_task_1 , condition_pre_task _2 ) ,
FAILURE ( condition_fail ) ,
FAILURE ( condition_pre_task_3 ) ,
) ,
) ,
)
)
end = Task ( name = " end " , task_type = TEST_TYPE )
condition = Conditions ( name = " conditions " , condition = cond_operator )
condition >> end
condition = Conditions ( name = TEST_NAME , condition = cond_operator )
parent >> condition
# General tasks test
# General tasks test
assert len ( pd . tasks ) == 5
assert len ( pd . tasks ) == 5
assert sorted ( pd . task_list , key = lambda t : t . name ) == sorted (
assert sorted ( pd . task_list , key = lambda t : t . name ) == sorted (
[
[
parent ,
condition ,
condition ,
condition_success_1 ,
condition_pre_task_1 ,
condition_success_2 ,
condition_pre_task_2 ,
condition_fail ,
condition_pre_task_3 ,
end ,
] ,
] ,
key = lambda t : t . name ,
key = lambda t : t . name ,
)
)
# Task dep test
# Task dep test
assert parent . _down stream_task_codes == { condition . code }
assert end . _up stream_task_codes == { condition . code }
assert condition . _upstream_task_codes == { parent . code }
assert condition . _downstream_task_codes == { end . code }
# Condition task dep after ProcessDefinition function get_define called
# Condition task dep after ProcessDefinition function get_define called
assert condition . _down stream_task_codes == {
assert condition . _up stream_task_codes == {
condition_success _1 . code ,
condition_pre_task _1 . code ,
condition_success _2 . code ,
condition_pre_task _2 . code ,
condition_fail . code ,
condition_pre_task_3 . code ,
}
}
assert all (
assert all (
[
[
child . _upstream_task_codes == { condition . code }
child . _downstream_task_codes == { condition . code }
for child in [ condition_success_1 , condition_success_2 , condition_fail ]
for child in [
condition_pre_task_1 ,
condition_pre_task_2 ,
condition_pre_task_3 ,
]
]
]
)
)