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'])
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)
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
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)
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)
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
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()
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()
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()
def test_setup_logging_log_file_False(self, controler): hamster_cli._setup_logging(controler) assert controler.lib_logger.handlers == [] assert controler.client_logger.handlers == []
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'])
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 == []