def test_configset_update(): # type: ignore cfg = ConfigurationSet( config_from_dict(DICT, lowercase_keys=True), config_from_dict(PROTECTED, lowercase_keys=True), ) assert len(cfg) == 17 assert cfg["a1.b2.c1"] == "a" cfg.update(NESTED) assert len(cfg) == 17 assert cfg["a1.b2.c1"] == "a0" cfg.update({"important_password_2": "abc"}) assert len(cfg) == 18
def test_configs(): # type: ignore # readable configs 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 cfg.configs[0] == config_from_dict(DICT2_1, lowercase_keys=True) cfg.configs = cfg.configs[1:] assert cfg.configs[0] == config_from_dict(DICT2_2, lowercase_keys=True) # writable configs 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), ) cfg.update({"abc": "xyz"}) assert cfg.configs[0] == config_from_dict(DICT2_1, lowercase_keys=True) cfg.configs = cfg.configs[1:] assert cfg.configs[0] == config_from_dict(DICT2_2, lowercase_keys=True)