# Path: crmsh/crash_test/utils.py
# CRED = '\033[31m'
# CYELLOW = '\033[33m'
# CGREEN = '\033[32m'
# CEND = '\033[0m'
# LEVEL = {
#     "info": logging.INFO,
#     "warn": logging.WARNING,
#     "error": logging.ERROR
# }
#     FORMAT_FLUSH = "[%(asctime)s]%(levelname)s: %(message)s"
#     FORMAT_NOFLUSH = "%(timestamp)s%(levelname)s: %(message)s"
#     COLORS = {
#         'WARNING': CYELLOW,
#         'INFO': CGREEN,
#         'ERROR': CRED
#     }
# class MyLoggingFormatter(logging.Formatter):
# class FenceInfo(object):
#     def __init__(self, flush=True):
#     def format(self, record):
# def now(form="%Y/%m/%d %H:%M:%S"):
# def manage_handler(_type, keep=True):
# def msg_raw(level, msg, to_stdout=True):
# def msg_info(msg, to_stdout=True):
# def msg_warn(msg, to_stdout=True):
# def msg_error(msg, to_stdout=True):
# def json_dumps():
#     def fence_enabled(self):
#     def fence_action(self):
#     def fence_timeout(self):
# def check_node_status(node, state):
# def online_nodes():
# def peer_node_list():
# def this_node():
# def str_to_datetime(str_time, fmt):
# def corosync_port_list():
# def get_handler(logger, _type):
# def is_root():
# def get_process_status(s):
# def _find_match_count(str1, str2):
# def is_valid_sbd(dev):
# def find_candidate_sbd(dev):
# def warning_ask(warn_string):
# 
# Path: crmsh/crash_test/main.py
# class Context(object):
# class MyArgParseFormatter(RawDescriptionHelpFormatter):
#     def __init__(self):
#     def __setattr__(self, name, value):
# def kill_process(context):
# def split_brain(context):
# def fence_node(context):
#     def __init__(self, prog):
# def parse_argument(context):
# def setup_basic_context(context):
# def run(context):


import os
import sys
    import mock
import logging
    from unittest import mock, TestCase
from crmsh.crash_test import utils, main, config
        utils.logger.removeHandler.assert_called_once_with("handler")
        utils.logger.addHandler.assert_called_once_with("handler")

    @mock.patch('crmsh.crash_test.utils.manage_handler')
    def test_msg_raw(self, mock_handler):
        utils.logger = mock.Mock()
        utils.logger.log = mock.Mock()
        utils.msg_raw("level1", "msg1")
        mock_handler.assert_called_once_with("console", True)
        utils.logger.log.assert_called_once_with("level1", "msg1")

    @mock.patch('crmsh.crash_test.utils.msg_raw')
    def test_msg_info(self, mock_raw):
        utils.msg_info("msg1")
        mock_raw.assert_called_once_with(logging.INFO, "msg1", True)

    @mock.patch('crmsh.crash_test.utils.msg_raw')
    def test_msg_warn(self, mock_raw):
        utils.msg_warn("msg1")
        mock_raw.assert_called_once_with(logging.WARNING, "msg1", True)

    @mock.patch('crmsh.crash_test.utils.msg_raw')
    def test_msg_error(self, mock_raw):
        utils.msg_error("msg1")
        mock_raw.assert_called_once_with(logging.ERROR, "msg1", True)

    @mock.patch('os.fsync')
    @mock.patch('json.dumps')
    @mock.patch('builtins.open', create=True)
    def test_json_dumps(self, mock_open_file, mock_dumps, mock_fsync):

# Path: crmsh/crash_test/utils.py
# CRED = '\033[31m'
# CYELLOW = '\033[33m'
# CGREEN = '\033[32m'
# CEND = '\033[0m'
# LEVEL = {
#     "info": logging.INFO,
#     "warn": logging.WARNING,
#     "error": logging.ERROR
# }
#     FORMAT_FLUSH = "[%(asctime)s]%(levelname)s: %(message)s"
#     FORMAT_NOFLUSH = "%(timestamp)s%(levelname)s: %(message)s"
#     COLORS = {
#         'WARNING': CYELLOW,
#         'INFO': CGREEN,
#         'ERROR': CRED
#     }
# class MyLoggingFormatter(logging.Formatter):
# class FenceInfo(object):
#     def __init__(self, flush=True):
#     def format(self, record):
# def now(form="%Y/%m/%d %H:%M:%S"):
# def manage_handler(_type, keep=True):
# def msg_raw(level, msg, to_stdout=True):
# def msg_info(msg, to_stdout=True):
# def msg_warn(msg, to_stdout=True):
# def msg_error(msg, to_stdout=True):
# def json_dumps():
#     def fence_enabled(self):
#     def fence_action(self):
#     def fence_timeout(self):
# def check_node_status(node, state):
# def online_nodes():
# def peer_node_list():
# def this_node():
# def str_to_datetime(str_time, fmt):
# def corosync_port_list():
# def get_handler(logger, _type):
# def is_root():
# def get_process_status(s):
# def _find_match_count(str1, str2):
# def is_valid_sbd(dev):
# def find_candidate_sbd(dev):
# def warning_ask(warn_string):
# 
# Path: crmsh/crash_test/main.py
# class Context(object):
# class MyArgParseFormatter(RawDescriptionHelpFormatter):
#     def __init__(self):
#     def __setattr__(self, name, value):
# def kill_process(context):
# def split_brain(context):
# def fence_node(context):
#     def __init__(self, prog):
# def parse_argument(context):
# def setup_basic_context(context):
# def run(context):


# Path: test/unittests/test_crashtest_utils.py
import os
import sys
    import mock
import logging
    from unittest import mock, TestCase
from crmsh.crash_test import utils, main, config

        utils.logger.removeHandler.assert_called_once_with("handler")
        utils.logger.addHandler.assert_called_once_with("handler")

    @mock.patch('crmsh.crash_test.utils.manage_handler')
    def test_msg_raw(self, mock_handler):
        utils.logger = mock.Mock()
        utils.logger.log = mock.Mock()
        utils.msg_raw("level1", "msg1")
        mock_handler.assert_called_once_with("console", True)
        utils.logger.log.assert_called_once_with("level1", "msg1")

    @mock.patch('crmsh.crash_test.utils.msg_raw')
    def test_msg_info(self, mock_raw):
        utils.msg_info("msg1")
        mock_raw.assert_called_once_with(logging.INFO, "msg1", True)

    @mock.patch('crmsh.crash_test.utils.msg_raw')
    def test_msg_warn(self, mock_raw):
        utils.msg_warn("msg1")
        mock_raw.assert_called_once_with(logging.WARNING, "msg1", True)

    @mock.patch('crmsh.crash_test.utils.msg_raw')
    def test_msg_error(self, mock_raw):
        utils.msg_error("msg1")
        mock_raw.assert_called_once_with(logging.ERROR, "msg1", True)

    @mock.patch('os.fsync')
    @mock.patch('json.dumps')
    @mock.patch('builtins.open', create=True)
    def test_json_dumps(self, mock_open_file, mock_dumps, mock_fsync):

        main.ctx = mock.Mock(jsonfile="file1", task_list={"process_name": "xin", "age": 38})