Ejemplo n.º 1
0
def test_save_empty():
    yaml_fo = tempfile.NamedTemporaryFile()

    config_ = config.Config()

    config.save(config_, yaml_fo.name)

    res_fo = open(yaml_fo.name, 'r')

    written_yaml = res_fo.read()
    log.debug('written_yaml: %s', written_yaml)

    assert written_yaml != ''
    assert 'server' in written_yaml
    assert 'collections_path' in written_yaml
Ejemplo n.º 2
0
def test_save():
    yaml_fo = tempfile.NamedTemporaryFile()

    config_ = config.Config()

    config_.options['some_option'] = 'some_option_value'

    config.save(config_, yaml_fo.name)

    res_fo = open(yaml_fo.name, 'r')

    written_yaml = res_fo.read()
    log.debug('written_yaml: %s', written_yaml)

    assert written_yaml != ''
    expected_strs = [
        'some_option',
        'some_option_value',
    ]
    for expected_str in expected_strs:
        assert expected_str in written_yaml, \
            'expected to find the string "%s" in written config file but did not. file contents: %s' % (expected_str, written_yaml)