# Path: cloudify/utils.py
# CFY_EXEC_TEMPDIR_ENVVAR = 'CFY_EXEC_TEMP'
# class ManagerVersion(object):
# class LocalCommandRunner(object):
# class CommandExecutionResponse(object):
# class Internal(object):
#     def __init__(self, raw_version):
#     def greater_than(self, other):
#     def equals(self, other):
#     def __str__(self):
#     def __eq__(self, other):
#     def __gt__(self, other):
#     def __lt__(self, other):
#     def __ge__(self, other):
#     def __le__(self, other):
#     def __ne__(self, other):
# def setup_logger(logger_name,
#                  logger_level=logging.INFO,
#                  handlers=None,
#                  remove_existing_handlers=True,
#                  logger_format=None,
#                  propagate=True):
# def format_exception(e):
# def get_manager_file_server_url():
# def get_manager_file_server_root():
# def get_manager_rest_service_host():
# def get_broker_ssl_cert_path():
# def get_manager_rest_service_port():
# def get_local_rest_certificate():
# def _get_current_context():
# def get_rest_token():
# def get_tenant():
# def get_tenant_name():
# def get_is_bypass_maintenance():
# def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
# def get_exec_tempdir():
# def create_temp_folder():
# def exception_to_error_cause(exception, tb):
#     def __init__(self, logger=None, host='localhost'):
#     def run(self, command,
#             exit_on_failure=True,
#             stdout_pipe=True,
#             stderr_pipe=True,
#             cwd=None,
#             execution_env=None):
#     def __init__(self, command, std_out, std_err, return_code):
# def _shlex_split(command):
#     def get_install_method(properties):
#     def get_broker_ssl_options(ssl_enabled, cert_path):
#     def get_broker_credentials(cloudify_agent):
#     def _get_package_version(plugins_dir, package_name):
#     def plugin_prefix(package_name=None, package_version=None,
#                       deployment_id=None, plugin_name=None, tenant_name=None,
#                       sys_prefix_fallback=True):
#     def _change_tenant(ctx, tenant):
# 
# Path: cloudify/event.py
# HIGH_VERBOSE = 3
# MEDIUM_VERBOSE = 2
# LOW_VERBOSE = 1
# NO_VERBOSE = 0
# class Event(object):
#     def __init__(self, event, verbosity_level=None):
#     def __str__(self):
#     def has_output(self):
#     def operation_info(self):
#     def text(self):
#     def log_level(self):
#     def timestamp(self):
#     def printable_timestamp(self):
#     def event_type_indicator(self):
#     def operation(self):
#     def node_id(self):
#     def source_id(self):
#     def target_id(self):
#     def deployment_id(self):
#     def event_type(self):
#     def is_log_message(self):


import sys
import testtools
from cloudify import utils
from cloudify import event

class TestEvent(testtools.TestCase):

    def test_event_has_output(self):
        test_event = _event('cloudify_event')
        self.assertTrue(test_event.has_output)
        test_event = _event('cloudify_log', level='INFO')
        self.assertTrue(test_event.has_output)
        test_event = _event('cloudify_log', level='DEBUG')
        self.assertFalse(test_event.has_output)
        test_event = _event('cloudify_log', level='DEBUG',
                            verbosity_level=event.MEDIUM_VERBOSE)
        self.assertTrue(test_event.has_output)

    def test_task_failure_causes(self):
        message = 'test_message'
        test_event = _event('cloudify_event',
                            event_type='task_failed',
                            message=message)
        self.assertEqual(test_event.text, message)
        causes = []
        test_event = _event('cloudify_event',
                            event_type='task_failed',
                            message=message,
                            causes=causes)
        self.assertEqual(test_event.text, message)
        try:
            raise RuntimeError()
        except RuntimeError:
            _, ex, tb = sys.exc_info()

# Path: cloudify/utils.py
# CFY_EXEC_TEMPDIR_ENVVAR = 'CFY_EXEC_TEMP'
# class ManagerVersion(object):
# class LocalCommandRunner(object):
# class CommandExecutionResponse(object):
# class Internal(object):
#     def __init__(self, raw_version):
#     def greater_than(self, other):
#     def equals(self, other):
#     def __str__(self):
#     def __eq__(self, other):
#     def __gt__(self, other):
#     def __lt__(self, other):
#     def __ge__(self, other):
#     def __le__(self, other):
#     def __ne__(self, other):
# def setup_logger(logger_name,
#                  logger_level=logging.INFO,
#                  handlers=None,
#                  remove_existing_handlers=True,
#                  logger_format=None,
#                  propagate=True):
# def format_exception(e):
# def get_manager_file_server_url():
# def get_manager_file_server_root():
# def get_manager_rest_service_host():
# def get_broker_ssl_cert_path():
# def get_manager_rest_service_port():
# def get_local_rest_certificate():
# def _get_current_context():
# def get_rest_token():
# def get_tenant():
# def get_tenant_name():
# def get_is_bypass_maintenance():
# def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
# def get_exec_tempdir():
# def create_temp_folder():
# def exception_to_error_cause(exception, tb):
#     def __init__(self, logger=None, host='localhost'):
#     def run(self, command,
#             exit_on_failure=True,
#             stdout_pipe=True,
#             stderr_pipe=True,
#             cwd=None,
#             execution_env=None):
#     def __init__(self, command, std_out, std_err, return_code):
# def _shlex_split(command):
#     def get_install_method(properties):
#     def get_broker_ssl_options(ssl_enabled, cert_path):
#     def get_broker_credentials(cloudify_agent):
#     def _get_package_version(plugins_dir, package_name):
#     def plugin_prefix(package_name=None, package_version=None,
#                       deployment_id=None, plugin_name=None, tenant_name=None,
#                       sys_prefix_fallback=True):
#     def _change_tenant(ctx, tenant):
# 
# Path: cloudify/event.py
# HIGH_VERBOSE = 3
# MEDIUM_VERBOSE = 2
# LOW_VERBOSE = 1
# NO_VERBOSE = 0
# class Event(object):
#     def __init__(self, event, verbosity_level=None):
#     def __str__(self):
#     def has_output(self):
#     def operation_info(self):
#     def text(self):
#     def log_level(self):
#     def timestamp(self):
#     def printable_timestamp(self):
#     def event_type_indicator(self):
#     def operation(self):
#     def node_id(self):
#     def source_id(self):
#     def target_id(self):
#     def deployment_id(self):
#     def event_type(self):
#     def is_log_message(self):


# Path: cloudify/tests/test_event.py
import sys
import testtools
from cloudify import utils
from cloudify import event


class TestEvent(testtools.TestCase):

    def test_event_has_output(self):
        test_event = _event('cloudify_event')
        self.assertTrue(test_event.has_output)
        test_event = _event('cloudify_log', level='INFO')
        self.assertTrue(test_event.has_output)
        test_event = _event('cloudify_log', level='DEBUG')
        self.assertFalse(test_event.has_output)
        test_event = _event('cloudify_log', level='DEBUG',
                            verbosity_level=event.MEDIUM_VERBOSE)
        self.assertTrue(test_event.has_output)

    def test_task_failure_causes(self):
        message = 'test_message'
        test_event = _event('cloudify_event',
                            event_type='task_failed',
                            message=message)
        self.assertEqual(test_event.text, message)
        causes = []
        test_event = _event('cloudify_event',
                            event_type='task_failed',
                            message=message,
                            causes=causes)
        self.assertEqual(test_event.text, message)
        try:
            raise RuntimeError()
        except RuntimeError:
            _, ex, tb = sys.exc_info()

            causes = [utils.exception_to_error_cause(ex, tb)]