Mercurial > piecrust2
comparison 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 |
comparison
equal
deleted
inserted
replaced
203:29165f2f315d | 204:f98451237371 |
---|---|
56 | 56 |
57 def test_config_has(): | 57 def test_config_has(): |
58 config = Configuration({'foo': 'bar'}) | 58 config = Configuration({'foo': 'bar'}) |
59 assert config.has('foo') is True | 59 assert config.has('foo') is True |
60 assert config.has('baz') is False | 60 assert config.has('baz') is False |
61 | |
62 | |
63 def test_config_deep_set_non_existing(): | |
64 config = Configuration({'foo': 'bar'}) | |
65 assert config.get('baz') is None | |
66 config.set('baz/or/whatever', 'something') | |
67 assert config.has('baz') is True | |
68 assert config.has('baz/or') is True | |
69 assert config.get('baz/or/whatever') == 'something' | |
70 | |
71 | |
72 def test_config_deep_set_existing(): | |
73 config = Configuration({'foo': 'bar', 'baz': {'wat': 'nothing'}}) | |
74 assert config.has('baz') is True | |
75 assert config.get('baz/wat') == 'nothing' | |
76 assert config.get('baz/or') is None | |
77 config.set('baz/or/whatever', 'something') | |
78 assert config.has('baz') is True | |
79 assert config.has('baz/or') is True | |
80 assert config.get('baz/or/whatever') == 'something' | |
61 | 81 |
62 | 82 |
63 @pytest.mark.parametrize('local, incoming, expected', [ | 83 @pytest.mark.parametrize('local, incoming, expected', [ |
64 ({}, {}, {}), | 84 ({}, {}, {}), |
65 ({'foo': 'bar'}, {}, {'foo': 'bar'}), | 85 ({'foo': 'bar'}, {}, {'foo': 'bar'}), |