# 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
# Copyright (c) 2012 - 2015 Lars Hupfeldt Nielsen, Hupfeldt IT
# All rights reserved. This work is under a BSD license, see LICENSE.TXT.




here = os.path.abspath(os.path.dirname(__file__))


_timestamp_re = re.compile(r't": [0-9]+.[0-9]+')


with open(jp(here, "json_test_compact.json")) as _jf:
    _compact_json = _jf.read().strip()


with open(jp(here, "json_test_pretty.json")) as _jf:
    _pretty_json = _jf.read().strip()


def _assert_json(got_json, expected_json, api_type):
    got_json = utils.replace_host_port(api_type, got_json)
    got_json = _timestamp_re.sub(r't": 12345.123', got_json)

    if api_type == ApiType.SCRIPT:

# 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

# Copyright (c) 2012 - 2015 Lars Hupfeldt Nielsen, Hupfeldt IT
# All rights reserved. This work is under a BSD license, see LICENSE.TXT.




here = os.path.abspath(os.path.dirname(__file__))


_timestamp_re = re.compile(r't": [0-9]+.[0-9]+')


with open(jp(here, "json_test_compact.json")) as _jf:
    _compact_json = _jf.read().strip()


with open(jp(here, "json_test_pretty.json")) as _jf:
    _pretty_json = _jf.read().strip()


def _assert_json(got_json, expected_json, api_type):
    got_json = utils.replace_host_port(api_type, got_json)
    got_json = _timestamp_re.sub(r't": 12345.123', got_json)

    if api_type == ApiType.SCRIPT:

        expected_json = utils.replace_host_port(api_type, expected_json)