def test_dict_methods_items():  # type: ignore
    cfg = ConfigurationSet(
        config_from_dict(DICT2_1, lowercase_keys=True),
        config_from_dict(DICT2_2, lowercase_keys=True),
        config_from_env(prefix=PREFIX, lowercase_keys=True),
    )

    assert dict(cfg.items()) == {
        "a1": {
            "b1.c1": "1",
            "b1.c2": "2",
            "b1.c3": "3",
            "b2.c1": "a",
            "b2.c2": "True",
            "b2.c3": "1.1",
        },
        "a2": {
            "b1.c1": "f",
            "b1.c2": False,
            "b1.c3": None,
            "b2.c1": 10,
            "b2.c2": "YWJjZGVmZ2g=",
            "b2.c3": "abcdefgh",
        },
    }

    with cfg.dotted_iter():
        assert dict(cfg.items()) == dict(
            [
                ("a2.b2.c2", "YWJjZGVmZ2g="),
                ("a1.b2.c2", "True"),
                ("a1.b2.c1", "a"),
                ("a1.b1.c2", "2"),
                ("a2.b2.c3", "abcdefgh"),
                ("a2.b1.c1", "f"),
                ("a1.b1.c3", "3"),
                ("a2.b1.c2", False),
                ("a2.b1.c3", None),
                ("a1.b1.c1", "1"),
                ("a2.b2.c1", 10),
                ("a1.b2.c3", "1.1"),
            ]
        )
Esempio n. 2
0
def test_dict_methods_items():  # type: ignore
    cfg = ConfigurationSet(
        config_from_dict(DICT2_1, lowercase_keys=True),
        config_from_dict(DICT2_2, lowercase_keys=True),
        config_from_env(prefix=PREFIX, lowercase_keys=True),
    )

    assert dict(cfg.items()) == dict(
        [
            ("a2.b2.c2", "YWJjZGVmZ2g="),
            ("a1.b2.c2", "True"),
            ("a1.b2.c1", "a"),
            ("a1.b1.c2", "2"),
            ("a2.b2.c3", "abcdefgh"),
            ("a2.b1.c1", "f"),
            ("a1.b1.c3", "3"),
            ("a2.b1.c2", False),
            ("a2.b1.c3", None),
            ("a1.b1.c1", "1"),
            ("a2.b2.c1", 10),
            ("a1.b2.c3", "1.1"),
        ]
    )