# Path: clearstack/common/util.py
# HOST_LOG_DIR = '/var/log/clearstack'
# HOST_LOG_FILE = "{0}/clearstack.log".format(HOST_LOG_DIR)
# LOG_DIR = '/var/log/clearstack'
#     LOG_DIR = '/tmp/log/clearstack'
# LOG_FILE = "{0}/clearstack.log".format(LOG_DIR)
# LOG = logging.getLogger("Clearstack")
# def _print_error_message(self, e, file_name):
# def port_open(port):
# def service_status(service):
# def service_enabled(service):
# def setup_debugging(debug, is_remote_host=True):
# def run_command(command, stdin=None, environ=None, debug=True):
# def str2bool(value):
# def write_config(file, data):
# def write_properties(file, data):
# def get_option(file, section, option):
# def delete_option(file, section, option=None):
# def write_in_file_ine(file, data):
# def get_dns():
# def get_netmask():
# def get_gateway():
# def get_net_interface():
# def get_ips():
# def get_nic(ip):
# def get_ip():
# def find_my_ip_from_config(config_ips):
# def is_localhost(host):
# def has_localhost(hosts):
# def remove_localhost(hosts):
# def ensure_directory(dir):
# def link_file(source, target):


import testtools
from clearstack.common import util
#




class ModulesUtilTest(testtools.TestCase):
    def setUp(self):
        super(ModulesUtilTest, self).setUp()

    # # Test if run_command is hidden debug logs
    # def test_0000_run_command(self):
    #     util.setup_debugging(True, False)
    #     util.run_command("echo", debug=False)
    #     logging.StreamHandler().close()
    #     self.assertEqual("echo" in open(self.log_file).read(), False)

    # # Test if run_command is showing debug logs
    # def test_0001_run_command(self):
    #     util.setup_debugging(True, False)
    #     util.run_command("echo")
    #     logging.StreamHandler().close()
    #     self.assertEqual("echo" in open(self.log_file).read(), True)

    # Test command not found
    def test_0002_run_command(self):
        self.assertRaises(Exception, util.run_command, "inexistente")

    # Test simple command
    def test_0003_run_command(self):
        try:

# Path: clearstack/common/util.py
# HOST_LOG_DIR = '/var/log/clearstack'
# HOST_LOG_FILE = "{0}/clearstack.log".format(HOST_LOG_DIR)
# LOG_DIR = '/var/log/clearstack'
#     LOG_DIR = '/tmp/log/clearstack'
# LOG_FILE = "{0}/clearstack.log".format(LOG_DIR)
# LOG = logging.getLogger("Clearstack")
# def _print_error_message(self, e, file_name):
# def port_open(port):
# def service_status(service):
# def service_enabled(service):
# def setup_debugging(debug, is_remote_host=True):
# def run_command(command, stdin=None, environ=None, debug=True):
# def str2bool(value):
# def write_config(file, data):
# def write_properties(file, data):
# def get_option(file, section, option):
# def delete_option(file, section, option=None):
# def write_in_file_ine(file, data):
# def get_dns():
# def get_netmask():
# def get_gateway():
# def get_net_interface():
# def get_ips():
# def get_nic(ip):
# def get_ip():
# def find_my_ip_from_config(config_ips):
# def is_localhost(host):
# def has_localhost(hosts):
# def remove_localhost(hosts):
# def ensure_directory(dir):
# def link_file(source, target):


# Path: clearstack/tests/test_modules_util.py
import testtools
from clearstack.common import util

#




class ModulesUtilTest(testtools.TestCase):
    def setUp(self):
        super(ModulesUtilTest, self).setUp()

    # # Test if run_command is hidden debug logs
    # def test_0000_run_command(self):
    #     util.setup_debugging(True, False)
    #     util.run_command("echo", debug=False)
    #     logging.StreamHandler().close()
    #     self.assertEqual("echo" in open(self.log_file).read(), False)

    # # Test if run_command is showing debug logs
    # def test_0001_run_command(self):
    #     util.setup_debugging(True, False)
    #     util.run_command("echo")
    #     logging.StreamHandler().close()
    #     self.assertEqual("echo" in open(self.log_file).read(), True)

    # Test command not found
    def test_0002_run_command(self):
        self.assertRaises(Exception, util.run_command, "inexistente")

    # Test simple command
    def test_0003_run_command(self):
        try:

            util.run_command("echo")