# Path: test/framework/api_select.py
# def api(file_name, api_type, login=None, fixed_prefix=None, url_or_dir=None, fake_public_uri=None, invocation_class=None,
#         username=None, password=None):


from pytest import raises
from jenkinsflow.flow import parallel, serial, BuildResult, FailedChildJobException, FinalResultException
from .framework import api_select
from .framework.cfg import jenkins_security
                ctrl2.invoke('j21')
                ctrl2.invoke('j22_unstable')
                ctrl2.invoke('j23')

        assert ctrl2.result == BuildResult.UNSTABLE
        assert ctrl1.result == BuildResult.UNSTABLE
        return 77


def test_propagate_unstable_parallel_inner(api_type):
    with api_select.api(__file__, api_type, login=True) as api:
        api.flow_job()
        api.job('j11', max_fails=0, expect_invocations=1, expect_order=1)
        api.job('j21', max_fails=0, expect_invocations=1, expect_order=2, serial=True)
        api.job('j22_unstable', max_fails=0, expect_invocations=1, expect_order=2, final_result='unstable')
        api.job('j23', max_fails=0, expect_invocations=1, expect_order=2)

        with serial(api, timeout=70, job_name_prefix=api.job_name_prefix, raise_if_unsuccessful=False) as ctrl1:
            ctrl1.invoke('j11')
            with ctrl1.parallel() as ctrl2:
                ctrl2.invoke('j21')
                ctrl2.invoke('j22_unstable')
                ctrl2.invoke('j23')

        assert ctrl2.result == BuildResult.UNSTABLE
        assert ctrl1.result == BuildResult.UNSTABLE
        return 77


def test_propagate_unstable_parallel_inner_raise_if_unsuccessful_true(api_type):

# Path: test/framework/api_select.py
# def api(file_name, api_type, login=None, fixed_prefix=None, url_or_dir=None, fake_public_uri=None, invocation_class=None,
#         username=None, password=None):


# Path: test/propagate_unstable_test.py
from pytest import raises
from jenkinsflow.flow import parallel, serial, BuildResult, FailedChildJobException, FinalResultException
from .framework import api_select
from .framework.cfg import jenkins_security

                ctrl2.invoke('j21')
                ctrl2.invoke('j22_unstable')
                ctrl2.invoke('j23')

        assert ctrl2.result == BuildResult.UNSTABLE
        assert ctrl1.result == BuildResult.UNSTABLE
        return 77


def test_propagate_unstable_parallel_inner(api_type):
    with api_select.api(__file__, api_type, login=True) as api:
        api.flow_job()
        api.job('j11', max_fails=0, expect_invocations=1, expect_order=1)
        api.job('j21', max_fails=0, expect_invocations=1, expect_order=2, serial=True)
        api.job('j22_unstable', max_fails=0, expect_invocations=1, expect_order=2, final_result='unstable')
        api.job('j23', max_fails=0, expect_invocations=1, expect_order=2)

        with serial(api, timeout=70, job_name_prefix=api.job_name_prefix, raise_if_unsuccessful=False) as ctrl1:
            ctrl1.invoke('j11')
            with ctrl1.parallel() as ctrl2:
                ctrl2.invoke('j21')
                ctrl2.invoke('j22_unstable')
                ctrl2.invoke('j23')

        assert ctrl2.result == BuildResult.UNSTABLE
        assert ctrl1.result == BuildResult.UNSTABLE
        return 77


def test_propagate_unstable_parallel_inner_raise_if_unsuccessful_true(api_type):

    with api_select.api(__file__, api_type, login=True) as api: