# 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
def test_flow_scope_job(api_type):
    with api_select.api(__file__, api_type) as api:
        api.flow_job()
        api.job('j1', max_fails=0, expect_invocations=0, expect_order=None)
        api.job('j2', max_fails=0, expect_invocations=0, expect_order=None)

        with raises(FlowScopeException):
            with serial(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                pass
            ctrl1.invoke('j1')

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

        with raises(FlowScopeException):
            with serial(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                with ctrl1.parallel() as ctrl2:
                    pass
                ctrl2.invoke('j2')

        with raises(FlowScopeException):
            with parallel(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                with ctrl1.serial() as ctrl2:
                    ctrl2.invoke('j1')
                ctrl2.invoke('j2')


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

def test_flow_scope_job(api_type):
    with api_select.api(__file__, api_type) as api:
        api.flow_job()
        api.job('j1', max_fails=0, expect_invocations=0, expect_order=None)
        api.job('j2', max_fails=0, expect_invocations=0, expect_order=None)

        with raises(FlowScopeException):
            with serial(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                pass
            ctrl1.invoke('j1')

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

        with raises(FlowScopeException):
            with serial(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                with ctrl1.parallel() as ctrl2:
                    pass
                ctrl2.invoke('j2')

        with raises(FlowScopeException):
            with parallel(api, 10, job_name_prefix=api.job_name_prefix) as ctrl1:
                with ctrl1.serial() as ctrl2:
                    ctrl2.invoke('j1')
                ctrl2.invoke('j2')


def test_flow_scope_serial(api_type):

    with api_select.api(__file__, api_type) as api: