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