# 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, FlowScopeException
from .framework import api_select
        with raises(FlowScopeException):
            with serial(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                with ctrl1.serial() as ctrl2:
                    ctrl2.serial(1)
                ctrl2.serial(1)

        with raises(FlowScopeException):
            with serial(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                with ctrl1.serial() as ctrl2:
                    ctrl1.serial(1)


def test_flow_scope_parallel(api_type):
    with api_select.api(__file__, api_type) as api:
        api.flow_job()

        with raises(FlowScopeException):
            with parallel(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                pass
            with ctrl1.parallel(1):
                pass

        with raises(FlowScopeException):
            with parallel(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                pass
            with ctrl1.serial(1):
                pass

        with raises(FlowScopeException):
            with parallel(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:

# 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/flow_scope_test.py
from pytest import raises
from jenkinsflow.flow import parallel, serial, FlowScopeException
from .framework import api_select

        with raises(FlowScopeException):
            with serial(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                with ctrl1.serial() as ctrl2:
                    ctrl2.serial(1)
                ctrl2.serial(1)

        with raises(FlowScopeException):
            with serial(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                with ctrl1.serial() as ctrl2:
                    ctrl1.serial(1)


def test_flow_scope_parallel(api_type):
    with api_select.api(__file__, api_type) as api:
        api.flow_job()

        with raises(FlowScopeException):
            with parallel(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                pass
            with ctrl1.parallel(1):
                pass

        with raises(FlowScopeException):
            with parallel(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                pass
            with ctrl1.serial(1):
                pass

        with raises(FlowScopeException):
            with parallel(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:

                with ctrl1.parallel() as ctrl2: