Skip to content

Commit

Permalink
user options override presets, not the other way around.
Browse files Browse the repository at this point in the history
  • Loading branch information
infothrill committed Feb 16, 2015
1 parent 3107465 commit 8a57b32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dyndnsc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def _iraw_client_configs(cfg):
if cfg.has_option(client_name, _use_preset):
prf = dict(
cfg.items(_preset_prefix + cfg.get(client_name, _use_preset)))
client_cfg_dict.update(prf)
prf.update(client_cfg_dict)
client_cfg_dict = prf
else:
# raw config with NO preset in use, so no updating of dict
pass
Expand Down
5 changes: 5 additions & 0 deletions dyndnsc/tests/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def test_collect_configuration(self):
use_preset = testpreset
updater-userid = bob
updater-password = XYZ
# test overwriting a preset value:
detector-url = http://myip.example.com/
[preset:testpreset]
updater = fubarUpdater
Expand All @@ -61,6 +63,9 @@ def test_collect_configuration(self):
self.assertTrue('detector' in config['testconfig'])
self.assertTrue(isinstance(config['testconfig']['detector'], list))
self.assertEqual(1, len(config['testconfig']['detector']))
detector, detector_opts = config['testconfig']['detector'][-1]
self.assertEqual(detector, "webcheck4") # from the preset
self.assertEqual(detector_opts['url'], "http://myip.example.com/") # from the user conf
self.assertTrue('updater' in config['testconfig'])
self.assertTrue(isinstance(config['testconfig']['updater'], list))
self.assertEqual(1, len(config['testconfig']['updater']))
Expand Down

0 comments on commit 8a57b32

Please sign in to comment.