# 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 result_msg(api, job_name, num=None):
#     if api.api_type == ApiType.SCRIPT:
#         return repr(job_name) + " - build: " + _script_api_log_file(job_name)
#     return repr(job_name) + " - build: http://x.x/job/" + job_name + "/" + (str(num) + "/console" if api.api_type == ApiType.MOCK and num else "")


from pytest import raises
from jenkinsflow.flow import serial, MessageRedefinedException
from .framework import api_select
from .framework.utils import lines_in, result_msg
                pctrl.invoke('j22')
                pctrl.invoke('j23')

        sout, _ = capsys.readouterr()
        print(sout)
        assert lines_in(
            api_type, sout,
            "^--- Starting flow ---",
            "^Flow Invocation (1/1,1/1): ['jenkinsflow_test__messages__j11', ['jenkinsflow_test__messages__j21'], 'jenkinsflow_test__messages__j12', (",
            "^Job Invocation (1/1,1/1): http://x.x/job/jenkinsflow_test__messages__j11",
            "^SUCCESS: " + result_msg(api, "jenkinsflow_test__messages__j11"),
            "^**** Message 1 ****",
            "^Flow Invocation (1/1,1/1): ['jenkinsflow_test__messages__j21']",
            "^Job Invocation (1/1,1/1): http://x.x/job/jenkinsflow_test__messages__j21",
            "^SUCCESS: " + result_msg(api, "jenkinsflow_test__messages__j21"),
            "^Flow SUCCESS ['jenkinsflow_test__messages__j21'] after: ",
            "^Job Invocation (1/1,1/1): http://x.x/job/jenkinsflow_test__messages__j12",
            "^SUCCESS: " + result_msg(api, "jenkinsflow_test__messages__j12"),
            "^==== Message 2 ====",
            "^Flow Invocation (1/1,1/1): ('jenkinsflow_test__messages__j22', 'jenkinsflow_test__messages__j23')",
            "^Job Invocation (1/1,1/1): http://x.x/job/jenkinsflow_test__messages__j22",
            "^Job Invocation (1/1,1/1): http://x.x/job/jenkinsflow_test__messages__j23",
            "^SUCCESS: " + result_msg(api, "jenkinsflow_test__messages__j22"),
            "^SUCCESS: " + result_msg(api, "jenkinsflow_test__messages__j23"),
            "^Flow SUCCESS ('jenkinsflow_test__messages__j22', 'jenkinsflow_test__messages__j23') after: ",
            "^Flow SUCCESS ['jenkinsflow_test__messages__j11', ['jenkinsflow_test__messages__j21'], 'jenkinsflow_test__messages__j12', ('jenkinsflow_test__messages__j22', 'jenkinsflow_test__messages__j23')]",
        )


def test_messages_on_job(api_type, capsys):

# 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 result_msg(api, job_name, num=None):
#     if api.api_type == ApiType.SCRIPT:
#         return repr(job_name) + " - build: " + _script_api_log_file(job_name)
#     return repr(job_name) + " - build: http://x.x/job/" + job_name + "/" + (str(num) + "/console" if api.api_type == ApiType.MOCK and num else "")


# Path: test/messages_test.py
from pytest import raises
from jenkinsflow.flow import serial, MessageRedefinedException
from .framework import api_select
from .framework.utils import lines_in, result_msg

                pctrl.invoke('j22')
                pctrl.invoke('j23')

        sout, _ = capsys.readouterr()
        print(sout)
        assert lines_in(
            api_type, sout,
            "^--- Starting flow ---",
            "^Flow Invocation (1/1,1/1): ['jenkinsflow_test__messages__j11', ['jenkinsflow_test__messages__j21'], 'jenkinsflow_test__messages__j12', (",
            "^Job Invocation (1/1,1/1): http://x.x/job/jenkinsflow_test__messages__j11",
            "^SUCCESS: " + result_msg(api, "jenkinsflow_test__messages__j11"),
            "^**** Message 1 ****",
            "^Flow Invocation (1/1,1/1): ['jenkinsflow_test__messages__j21']",
            "^Job Invocation (1/1,1/1): http://x.x/job/jenkinsflow_test__messages__j21",
            "^SUCCESS: " + result_msg(api, "jenkinsflow_test__messages__j21"),
            "^Flow SUCCESS ['jenkinsflow_test__messages__j21'] after: ",
            "^Job Invocation (1/1,1/1): http://x.x/job/jenkinsflow_test__messages__j12",
            "^SUCCESS: " + result_msg(api, "jenkinsflow_test__messages__j12"),
            "^==== Message 2 ====",
            "^Flow Invocation (1/1,1/1): ('jenkinsflow_test__messages__j22', 'jenkinsflow_test__messages__j23')",
            "^Job Invocation (1/1,1/1): http://x.x/job/jenkinsflow_test__messages__j22",
            "^Job Invocation (1/1,1/1): http://x.x/job/jenkinsflow_test__messages__j23",
            "^SUCCESS: " + result_msg(api, "jenkinsflow_test__messages__j22"),
            "^SUCCESS: " + result_msg(api, "jenkinsflow_test__messages__j23"),
            "^Flow SUCCESS ('jenkinsflow_test__messages__j22', 'jenkinsflow_test__messages__j23') after: ",
            "^Flow SUCCESS ['jenkinsflow_test__messages__j11', ['jenkinsflow_test__messages__j21'], 'jenkinsflow_test__messages__j12', ('jenkinsflow_test__messages__j22', 'jenkinsflow_test__messages__j23')]",
        )


def test_messages_on_job(api_type, capsys):

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