# 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 _script_api_log_file(job_name):
# def console_url(api, job_name, num):
# def result_msg(api, job_name, num=None):
# def build_started_msg(api, job_name, num, invocation_number=0):
# def kill_current_msg(api, job_name, num):
# def build_queued_msg(api, job_name, num):
# def replace_host_port(api_type, contains_url):
# def lines_in(api_type, text, *expected_lines):
# def flow_graph_dir(flow_name):
# 
# Path: test/framework/utils.py
# def flow_graph_dir(flow_name):
#     """Control which directory to put flow graph in.
# 
#     Put the generated graph in the workspace root if running from Jenkins.
#     If running from commandline put it under config.flow_graph_root_dir/flow_name
# 
#     Return: dir-name
#     """
#     return '.' if os.environ.get('JOB_NAME') else jp(flow_graph_root_dir, flow_name)
# 
# Path: test/cfg.py
# class ApiType(Enum):
#     JENKINS = 0
#     SCRIPT = 1
#     MOCK = 2


import os
import re
from os.path import join as jp
from jenkinsflow.flow import serial
from .framework import api_select, utils
from .framework.utils import flow_graph_dir
from .cfg import ApiType
            print("--- got json ---")
            print(got_json)
        assert got_json.strip() == expected_json


def _flow(api, strip_prefix, json_dir):
    if not os.path.exists(json_dir):
        os.makedirs(json_dir)

    with serial(api, timeout=70, job_name_prefix=api.job_name_prefix, report_interval=1, json_dir=json_dir, json_strip_top_level_prefix=strip_prefix) as ctrl1:
        ctrl1.invoke('j1')
        ctrl1.invoke('j2')

        with ctrl1.parallel(timeout=40, report_interval=3) as ctrl2:
            with ctrl2.serial(timeout=40, report_interval=3) as ctrl3a:
                ctrl3a.invoke('j3')
                ctrl3a.invoke('j6')
                ctrl3a.invoke_unchecked('j7_unchecked')

            with ctrl2.parallel(timeout=40, report_interval=3) as ctrl3b:
                ctrl3b.invoke('j4')
                ctrl3b.invoke('j5')
                ctrl3b.invoke_unchecked('j8_unchecked')

        ctrl1.invoke('j9')

    return ctrl1


def test_json_strip_prefix(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/framework/utils.py
# def _script_api_log_file(job_name):
# def console_url(api, job_name, num):
# def result_msg(api, job_name, num=None):
# def build_started_msg(api, job_name, num, invocation_number=0):
# def kill_current_msg(api, job_name, num):
# def build_queued_msg(api, job_name, num):
# def replace_host_port(api_type, contains_url):
# def lines_in(api_type, text, *expected_lines):
# def flow_graph_dir(flow_name):
# 
# Path: test/framework/utils.py
# def flow_graph_dir(flow_name):
#     """Control which directory to put flow graph in.
# 
#     Put the generated graph in the workspace root if running from Jenkins.
#     If running from commandline put it under config.flow_graph_root_dir/flow_name
# 
#     Return: dir-name
#     """
#     return '.' if os.environ.get('JOB_NAME') else jp(flow_graph_root_dir, flow_name)
# 
# Path: test/cfg.py
# class ApiType(Enum):
#     JENKINS = 0
#     SCRIPT = 1
#     MOCK = 2


# Path: test/json_test.py
import os
import re
from os.path import join as jp
from jenkinsflow.flow import serial
from .framework import api_select, utils
from .framework.utils import flow_graph_dir
from .cfg import ApiType

            print("--- got json ---")
            print(got_json)
        assert got_json.strip() == expected_json


def _flow(api, strip_prefix, json_dir):
    if not os.path.exists(json_dir):
        os.makedirs(json_dir)

    with serial(api, timeout=70, job_name_prefix=api.job_name_prefix, report_interval=1, json_dir=json_dir, json_strip_top_level_prefix=strip_prefix) as ctrl1:
        ctrl1.invoke('j1')
        ctrl1.invoke('j2')

        with ctrl1.parallel(timeout=40, report_interval=3) as ctrl2:
            with ctrl2.serial(timeout=40, report_interval=3) as ctrl3a:
                ctrl3a.invoke('j3')
                ctrl3a.invoke('j6')
                ctrl3a.invoke_unchecked('j7_unchecked')

            with ctrl2.parallel(timeout=40, report_interval=3) as ctrl3b:
                ctrl3b.invoke('j4')
                ctrl3b.invoke('j5')
                ctrl3b.invoke_unchecked('j8_unchecked')

        ctrl1.invoke('j9')

    return ctrl1


def test_json_strip_prefix(api_type):

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