Пример #1
0
 def test_setup_logging(self, controler, client_config, lib_config):
     """Test that library and client logger have log level set according to config."""
     hamster_cli._setup_logging(controler)
     assert controler.lib_logger.level == (
         controler.client_config['log_level'])
     assert controler.client_logger.level == (
         controler.client_config['log_level'])
Пример #2
0
 def test_setup_logging(self, controler, client_config, lib_config):
     """Test that library and client logger have log level set according to config."""
     hamster_cli._setup_logging(controler)
     assert controler.lib_logger.level == (
         controler.client_config['log_level'])
     assert controler.client_logger.level == (
         controler.client_config['log_level'])
Пример #3
0
 def test_setup_logging_log_file_True(self, controler):
     controler.client_config['log_file'] = True
     controler.client_config['log_filename'] = 'foobar.log'
     hamster_cli._setup_logging(controler)
     assert isinstance(controler.lib_logger.handlers[0],
         logging.FileHandler)
     assert isinstance(controler.client_logger.handlers[0],
         logging.FileHandler)
Пример #4
0
 def test_setup_logging_log_console_True(self, controler):
     controler.client_config['log_console'] = True
     hamster_cli._setup_logging(controler)
     assert isinstance(controler.client_logger.handlers[0],
         logging.StreamHandler)
     assert isinstance(controler.lib_logger.handlers[0],
         logging.StreamHandler)
     assert controler.client_logger.handlers[0].formatter
Пример #5
0
 def test_setup_logging_log_file_true(self, controler, appdirs):
     """Make sure that if we enable a logfile_path, both loggers recieve a ``FileHandler``."""
     controler.client_config['logfile_path'] = os.path.join(appdirs.user_log_dir, 'foobar.log')
     hamster_cli._setup_logging(controler)
     assert isinstance(controler.lib_logger.handlers[0],
         logging.FileHandler)
     assert isinstance(controler.client_logger.handlers[0],
         logging.FileHandler)
Пример #6
0
 def test_setup_logging_log_file_true(self, controler, appdirs):
     """Make sure that if we enable a logfile_path, both loggers recieve a ``FileHandler``."""
     controler.client_config['logfile_path'] = os.path.join(
         appdirs.user_log_dir, 'foobar.log')
     hamster_cli._setup_logging(controler)
     assert isinstance(controler.lib_logger.handlers[0],
                       logging.FileHandler)
     assert isinstance(controler.client_logger.handlers[0],
                       logging.FileHandler)
Пример #7
0
 def test_setup_logging_log_console_true(self, controler):
     """Make sure that if console loggin is on lib and client logger have a streamhandler."""
     controler.client_config['log_console'] = True
     hamster_cli._setup_logging(controler)
     assert isinstance(controler.client_logger.handlers[0],
                       logging.StreamHandler)
     assert isinstance(controler.lib_logger.handlers[0],
                       logging.StreamHandler)
     assert controler.client_logger.handlers[0].formatter
Пример #8
0
def controler_with_logging(lib_config, client_config):
    """Provide a pseudo controler instance with logging setup."""
    controler = hamsterlib.HamsterControl(lib_config)
    controler.client_config = client_config
    # [FIXME]
    # We souldn't shortcut like this!
    hamster_cli._setup_logging(controler)
    yield controler
    controler.store.cleanup()
Пример #9
0
 def test_setup_logging_log_console_true(self, controler):
     """Make sure that if console loggin is on lib and client logger have a streamhandler."""
     controler.client_config['log_console'] = True
     hamster_cli._setup_logging(controler)
     assert isinstance(controler.client_logger.handlers[0],
         logging.StreamHandler)
     assert isinstance(controler.lib_logger.handlers[0],
         logging.StreamHandler)
     assert controler.client_logger.handlers[0].formatter
Пример #10
0
def controler_with_logging(lib_config, client_config):
    controler = hamsterlib.HamsterControl(lib_config)
    controler.client_config = client_config
    # [FIXME]
    # We souldn't shortcut like this!
    hamster_cli._setup_logging(controler)
    yield controler
    if os.path.isfile(os.path.join(lib_config['work_dir'],
            lib_config['tmpfile_name'])):
        os.remove(os.path.join(lib_config['work_dir'],
            lib_config['tmpfile_name']))
    controler.store.cleanup()
Пример #11
0
def controler_with_logging(lib_config, client_config):
    controler = hamsterlib.HamsterControl(lib_config)
    controler.client_config = client_config
    # [FIXME]
    # We souldn't shortcut like this!
    hamster_cli._setup_logging(controler)
    yield controler
    if os.path.isfile(
            os.path.join(lib_config['work_dir'], lib_config['tmpfile_name'])):
        os.remove(
            os.path.join(lib_config['work_dir'], lib_config['tmpfile_name']))
    controler.store.cleanup()
Пример #12
0
 def test_setup_logging_log_file_False(self, controler):
     hamster_cli._setup_logging(controler)
     assert controler.lib_logger.handlers == []
     assert controler.client_logger.handlers == []
Пример #13
0
 def test_setup_logging(self, controler, client_config, lib_config):
     hamster_cli._setup_logging(controler)
     assert controler.lib_logger.level == (
         controler.client_config['log_level'])
     assert controler.client_logger.level == (
         controler.client_config['log_level'])
Пример #14
0
 def test_setup_logging_no_logging(self, controler):
     """Make sure that if no logging enabled, our loggers don't have any handlers."""
     hamster_cli._setup_logging(controler)
     assert controler.lib_logger.handlers == []
     assert controler.client_logger.handlers == []
Пример #15
0
 def test_setup_logging_no_logging(self, controler):
     """Make sure that if no logging enabled, our loggers don't have any handlers."""
     hamster_cli._setup_logging(controler)
     assert controler.lib_logger.handlers == []
     assert controler.client_logger.handlers == []