Ejemplo n.º 1
0
def test_process_conf_dir(conf_dir):
    parser = create_conf_parser(str(conf_dir))
    obj = process_conf_files(parser)
    assert sorted(obj.keys()) == ["beverage", "food", "pet"]
    assert sorted(obj["beverage"].keys()) == ["Coffee", "Milk", "Tea"]
    assert sorted(obj["food"].keys()) == ["Bacon", "Egg", "Spam"]
    assert sorted(obj["pet"].keys()) == ["Cat", "Dog", "Snake"]
    assert obj["food"]["Bacon"] == {"taste": "Delicious"}
    assert obj["food"]["Spam"] == {"taste": "Sublime"}
Ejemplo n.º 2
0
def test_process_conf_files():
    example_conf = textwrap.dedent(
        """
    [food:Egg]
    description = A nice round egg

    [food:Spam]
    description = Spam Spam Spam Spam Spam!

    [person:JohnDoe]
    first_name = John
    last_name = Doe
    """
    )
    expected_result = {
        "food": {"Egg": {"description": "A nice round egg"}, "Spam": {"description": "Spam Spam Spam Spam Spam!"}},
        "person": {"JohnDoe": {"first_name": "John", "last_name": "Doe"}},
    }
    conf_parser = RawConfigParser()
    conf_parser.readfp(io.BytesIO(example_conf))
    result = process_conf_files(conf_parser)
    assert result == expected_result
    pass