def test_logger_logs_errors(caplog, dietstorage):
    del dietstorage.config['commands']
    filename = 'stockholm.jpg'
    path = join(THIS_DIR, 'test_files', 'stockholm.jpg')
    tmppath = join(dietstorage.temp_dir, filename)
    try:
        dietstorage.save(path, open(path, 'rb'))
    except storage.diet.DietException as e:
        assert (not exists(tmppath))
        assert isinstance(e, storage.diet.ConfigurationErrorDietException)
    records = list(caplog.records())
    assert (len(records) == 1)
    record = records[0]
    assert (record.levelname == 'ERROR')
    assert record.message.startswith('Missing key(s) in configuration: ')
def test_logger_logs_errors(caplog, dietstorage):
    del dietstorage.config['commands']
    filename = 'stockholm.jpg'
    path = join(THIS_DIR, 'test_files', 'stockholm.jpg')
    tmppath = join(dietstorage.temp_dir, filename)
    try:
        dietstorage.save(path, open(path, 'rb'))
    except storage.diet.DietException as e:
        assert (not exists(tmppath))
        assert isinstance(e, storage.diet.ConfigurationErrorDietException)
    records = list(caplog.records())
    assert (len(records) == 1)
    record = records[0]
    assert (record.levelname == 'ERROR')
    assert record.message.startswith('Missing key(s) in configuration: ')