示例#1
0
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)
示例#2
0
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'
示例#3
0
def logger():
    return Logger()
示例#4
0
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()
示例#5
0
def test_logger_output(logger_mock):
    logger = Logger(output='mylog')
    logger.add_handler.assert_called_with(50, 'mylog')
示例#6
0
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')
示例#7
0
def test_init(logger_mock):
    logger = Logger()
    logger.start_logger.assert_called_with(50)
    logger.add_handler.assert_called_with(50, 'stdout')
示例#8
0
def logger(mocker):
    mocker.patch.object(logging, 'getLogger')
    return Logger()