# 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
        api.job('j3', max_fails=0, expect_invocations=1, expect_order=3)
        api.job('j4', max_fails=0, expect_invocations=1, expect_order=3)
        api.job('j5', max_fails=0, expect_invocations=1, expect_order=3)
        api.job('j6', max_fails=0, expect_invocations=1, expect_order=3)
        api.job('j7_unchecked', max_fails=0, expect_invocations=1, invocation_delay=0, exec_time=40, expect_order=None, unknown_result=True)
        api.job('j8_unchecked', max_fails=0, expect_invocations=1, invocation_delay=0, exec_time=40, expect_order=None, unknown_result=True)
        api.job('j9', max_fails=0, expect_invocations=1, expect_order=4, exec_time=5)

        ctrl1 = _flow(api, False, flow_graph_dir(flow_name))

        # Test pretty printing with no stripping of top level prefix
        json_file = jp(flow_graph_dir(flow_name), "verbose_pretty.json")
        ctrl1.json(json_file, indent=4)
        with open(json_file) as jf:
            got_json = jf.read().strip()
            expect_json = _pretty_json.replace('strip_prefix', 'no_strip_prefix').replace('name": "', 'name": "jenkinsflow_test__json_no_strip_prefix__')
            _assert_json(got_json, expect_json, api.api_type)


def test_json_unchecked_only_in_flows(api_type):
    with api_select.api(__file__, api_type, login=True) as api:
        flow_name = api.flow_job()
        api.job('j1_unchecked', max_fails=0, expect_invocations=1, invocation_delay=0, exec_time=40, expect_order=None, unknown_result=True)
        api.job('j2_unchecked', max_fails=0, expect_invocations=1, expect_order=None)
        api.job('j3_unchecked', max_fails=0, expect_invocations=1, invocation_delay=0, exec_time=40, expect_order=None, unknown_result=True)
        api.job('j4_unchecked', max_fails=0, expect_invocations=1, invocation_delay=0, exec_time=40, expect_order=None, unknown_result=True)
        api.job('j5_unchecked', max_fails=0, expect_invocations=1, expect_order=None)
        api.job('j6', max_fails=0, expect_invocations=1, expect_order=1)
        api.job('j7', max_fails=0, expect_invocations=1, expect_order=2, exec_time=5)


# 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

        api.job('j3', max_fails=0, expect_invocations=1, expect_order=3)
        api.job('j4', max_fails=0, expect_invocations=1, expect_order=3)
        api.job('j5', max_fails=0, expect_invocations=1, expect_order=3)
        api.job('j6', max_fails=0, expect_invocations=1, expect_order=3)
        api.job('j7_unchecked', max_fails=0, expect_invocations=1, invocation_delay=0, exec_time=40, expect_order=None, unknown_result=True)
        api.job('j8_unchecked', max_fails=0, expect_invocations=1, invocation_delay=0, exec_time=40, expect_order=None, unknown_result=True)
        api.job('j9', max_fails=0, expect_invocations=1, expect_order=4, exec_time=5)

        ctrl1 = _flow(api, False, flow_graph_dir(flow_name))

        # Test pretty printing with no stripping of top level prefix
        json_file = jp(flow_graph_dir(flow_name), "verbose_pretty.json")
        ctrl1.json(json_file, indent=4)
        with open(json_file) as jf:
            got_json = jf.read().strip()
            expect_json = _pretty_json.replace('strip_prefix', 'no_strip_prefix').replace('name": "', 'name": "jenkinsflow_test__json_no_strip_prefix__')
            _assert_json(got_json, expect_json, api.api_type)


def test_json_unchecked_only_in_flows(api_type):
    with api_select.api(__file__, api_type, login=True) as api:
        flow_name = api.flow_job()
        api.job('j1_unchecked', max_fails=0, expect_invocations=1, invocation_delay=0, exec_time=40, expect_order=None, unknown_result=True)
        api.job('j2_unchecked', max_fails=0, expect_invocations=1, expect_order=None)
        api.job('j3_unchecked', max_fails=0, expect_invocations=1, invocation_delay=0, exec_time=40, expect_order=None, unknown_result=True)
        api.job('j4_unchecked', max_fails=0, expect_invocations=1, invocation_delay=0, exec_time=40, expect_order=None, unknown_result=True)
        api.job('j5_unchecked', max_fails=0, expect_invocations=1, expect_order=None)
        api.job('j6', max_fails=0, expect_invocations=1, expect_order=1)
        api.job('j7', max_fails=0, expect_invocations=1, expect_order=2, exec_time=5)


        json_dir = flow_graph_dir(flow_name)