def test_add_handler(mocker): mocker.patch.object(logging, 'FileHandler') mocker.patch.object(logging, 'getLogger') logger = Logger(output='mylog') logging.FileHandler.assert_called_with('mylog') logging.FileHandler().setLevel.assert_called_with(logging.CRITICAL) logging.getLogger().addHandler.assert_called_with(logging.FileHandler()) assert isinstance(logger, Logger)
def test_get(interface, donor_setup, receiver_setup, tracker_setup): targets = Targets(interface.donor(), Logger()) sources = [{'table': 'users'}, {'table': 'addresses', 'on': 'user'}] items = targets.get(sources) results = [] for item in items: results.append(item) assert results[0].username == 'gandalf' assert results[0].addresses.city == 'shire' assert results[1].username == 'saruman' assert results[1].addresses.city == 'orthanc' assert results[2].username == 'elrond' assert results[2].addresses.city == 'rivendell'
def logger(): return Logger()
def test_start_logger(mocker): mocker.patch.object(logging, 'getLogger') logger = Logger() logging.getLogger.assert_called_with('magnivore') logging.getLogger().setLevel.assert_called_with(logging.CRITICAL) assert logger.logger == logging.getLogger()
def test_logger_output(logger_mock): logger = Logger(output='mylog') logger.add_handler.assert_called_with(50, 'mylog')
def test_init_verbosities(logger_mock, verbosity, level): logger = Logger(verbosity=verbosity) logger.start_logger.assert_called_with(level) logger.add_handler.assert_called_with(level, 'stdout')
def test_init(logger_mock): logger = Logger() logger.start_logger.assert_called_with(50) logger.add_handler.assert_called_with(50, 'stdout')
def logger(mocker): mocker.patch.object(logging, 'getLogger') return Logger()