Mercurial > piecrust2
diff tests/test_configuration.py @ 204:f98451237371
internal: Add ability to get a default value if a config value doesn't exist.
tests: Add some configuration tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 18 Jan 2015 11:53:18 -0800 |
parents | 10fc9c8bf682 |
children | 32c7c2d219d2 |
line wrap: on
line diff
--- a/tests/test_configuration.py Thu Jan 15 22:54:59 2015 -0800 +++ b/tests/test_configuration.py Sun Jan 18 11:53:18 2015 -0800 @@ -60,6 +60,26 @@ assert config.has('baz') is False +def test_config_deep_set_non_existing(): + config = Configuration({'foo': 'bar'}) + assert config.get('baz') is None + config.set('baz/or/whatever', 'something') + assert config.has('baz') is True + assert config.has('baz/or') is True + assert config.get('baz/or/whatever') == 'something' + + +def test_config_deep_set_existing(): + config = Configuration({'foo': 'bar', 'baz': {'wat': 'nothing'}}) + assert config.has('baz') is True + assert config.get('baz/wat') == 'nothing' + assert config.get('baz/or') is None + config.set('baz/or/whatever', 'something') + assert config.has('baz') is True + assert config.has('baz/or') is True + assert config.get('baz/or/whatever') == 'something' + + @pytest.mark.parametrize('local, incoming, expected', [ ({}, {}, {}), ({'foo': 'bar'}, {}, {'foo': 'bar'}),