diff --git a/src/wuttjamaican/conf.py b/src/wuttjamaican/conf.py index 7922a1f..081ad5a 100644 --- a/src/wuttjamaican/conf.py +++ b/src/wuttjamaican/conf.py @@ -329,6 +329,8 @@ class WuttaConfig: if not isinstance(value, configuration.Configuration): return value + log.warning("ambiguous config key '%s' returns: %s", key, value) + # read from db last if so requested if usedb and not preferdb: value = self.get_from_db(key, session=session) diff --git a/tests/test_conf.py b/tests/test_conf.py index 213a0e1..c0d95ae 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -336,6 +336,17 @@ configure_logging = true session.close() + def test_get_ambiguous(self): + config = conf.WuttaConfig() + + # value is returned if key is not ambiguous + config.setdefault('foo', 'bar') + self.assertEqual(config.get('foo'), 'bar') + + # but None is returned if key is ambiguous + config.setdefault('foo.bar', 'baz') + self.assertIsNone(config.get('foo')) + def test_require(self): config = conf.WuttaConfig() self.assertRaises(ConfigurationError, config.require, 'foo')