# Path: test/cfg.py
# class ApiType(Enum):
#     JENKINS = 0
#     SCRIPT = 1
#     MOCK = 2
# 
# 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/framework/utils.py
# def lines_in(api_type, text, *expected_lines):
#     """Assert that `*expected_lines` occur in order in the lines of `text`.
# 
#     Args:
#         *expected_lines (str or RegexObject (hasattr `match`)): For each `expected_line` in expected_lines:
#             If `expected_line` has a match method it is called and must return True for a line in `text`.
#             Otherwise, if the `expected_line` starts with '^', a line in `text` must start with `expected_line[1:]`
#             Otherwise `expected line` must simply occur in a line in `text`
#     """
# 
#     assert isinstance(api_type, test_cfg.ApiType)
#     assert text
#     assert expected_lines
# 
#     return generic_lines_in(text, partial(replace_host_port, api_type), *expected_lines)
# 
# def build_started_msg(api, job_name, num, invocation_number=0):
#     return "Build started: " + repr(job_name) + ((' Invocation-' + repr(invocation_number)) if invocation_number else '') + " - " + console_url(api, job_name, num)


import os, re
import pytest
from pytest import xfail
from jenkinsflow.flow import serial, parallel
from .cfg import ApiType
from .framework import api_select
from .framework.utils import lines_in, build_started_msg
        sout, _ = capsys.readouterr()
        assert lines_in(
            api_type, sout,
            "^Job Invocation-1 (1/1,1/1): http://x.x/job/jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1",
            "^Job Invocation-2 (1/1,1/1): http://x.x/job/jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1",
            "^Job Invocation-3 (1/1,1/1): http://x.x/job/jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1",
            (
                build_started_msg(api, "jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1", 1, invocation_number=1),
                "^job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-1 stopped running",
                "^job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-1 Status IDLE - build: #",
                "^SUCCESS: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-1",

                build_started_msg(api, "jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1", 2, invocation_number=2),
                "^job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-2 stopped running",
                "^job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-2 Status IDLE - build: #",
                "^SUCCESS: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-2",

                build_started_msg(api, "jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1", 3, invocation_number=3),
                "^job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-3 stopped running",
                "^job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-3 Status IDLE - build: #",
                "^SUCCESS: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-3",
            ),
            "^parallel flow: (",
            "job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-1 SUCCESS",
            "job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-2 SUCCESS",
            "job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-3 SUCCESS",
            "^)",
        )



# Path: test/cfg.py
# class ApiType(Enum):
#     JENKINS = 0
#     SCRIPT = 1
#     MOCK = 2
# 
# 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/framework/utils.py
# def lines_in(api_type, text, *expected_lines):
#     """Assert that `*expected_lines` occur in order in the lines of `text`.
# 
#     Args:
#         *expected_lines (str or RegexObject (hasattr `match`)): For each `expected_line` in expected_lines:
#             If `expected_line` has a match method it is called and must return True for a line in `text`.
#             Otherwise, if the `expected_line` starts with '^', a line in `text` must start with `expected_line[1:]`
#             Otherwise `expected line` must simply occur in a line in `text`
#     """
# 
#     assert isinstance(api_type, test_cfg.ApiType)
#     assert text
#     assert expected_lines
# 
#     return generic_lines_in(text, partial(replace_host_port, api_type), *expected_lines)
# 
# def build_started_msg(api, job_name, num, invocation_number=0):
#     return "Build started: " + repr(job_name) + ((' Invocation-' + repr(invocation_number)) if invocation_number else '') + " - " + console_url(api, job_name, num)


# Path: test/multiple_invocations_test.py
import os, re
import pytest
from pytest import xfail
from jenkinsflow.flow import serial, parallel
from .cfg import ApiType
from .framework import api_select
from .framework.utils import lines_in, build_started_msg

        sout, _ = capsys.readouterr()
        assert lines_in(
            api_type, sout,
            "^Job Invocation-1 (1/1,1/1): http://x.x/job/jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1",
            "^Job Invocation-2 (1/1,1/1): http://x.x/job/jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1",
            "^Job Invocation-3 (1/1,1/1): http://x.x/job/jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1",
            (
                build_started_msg(api, "jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1", 1, invocation_number=1),
                "^job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-1 stopped running",
                "^job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-1 Status IDLE - build: #",
                "^SUCCESS: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-1",

                build_started_msg(api, "jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1", 2, invocation_number=2),
                "^job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-2 stopped running",
                "^job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-2 Status IDLE - build: #",
                "^SUCCESS: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-2",

                build_started_msg(api, "jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1", 3, invocation_number=3),
                "^job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-3 stopped running",
                "^job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-3 Status IDLE - build: #",
                "^SUCCESS: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-3",
            ),
            "^parallel flow: (",
            "job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-1 SUCCESS",
            "job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-2 SUCCESS",
            "job: 'jenkinsflow_test__multiple_invocations_parallel_same_flow_queued__j1' Invocation-3 SUCCESS",
            "^)",
        )



@pytest.mark.not_apis(ApiType.MOCK, ApiType.SCRIPT)