def test_update(self):
     """Test update()."""
     ucr = ConfigRegistry()
     ucr['foo'] = 'foo'
     ucr['bar'] = 'bar'
     ucr.update({
         'foo': None,
         'bar': 'baz',
         'baz': 'bar',
     })
     self.assertEqual(ucr.get('foo'), None)
     self.assertEqual(ucr.get('bar'), 'baz')
     self.assertEqual(ucr.get('baz'), 'bar')
def _register_variable_default_values(ucr):
    # type: (ConfigRegistry) -> None
    """Create base-default.conf layer containig all default values"""
    info = _get_config_registry_info()
    _ucr = ConfigRegistry(write_registry=ConfigRegistry.DEFAULTS)
    _ucr.load()
    defaults = {}  # type: Dict[str, Optional[str]]
    default_variables = info.get_variables()
    for key, variable in default_variables.items():
        value = variable.get('default')
        if value:
            defaults[key] = value
    for key in _ucr:
        if key not in default_variables:
            defaults[key] = None

    changed = dict((key, (old, new))
                   for key, (old, new) in _ucr.update(defaults).items()
                   if old != new)
    _ucr.save()
    ucr.load()
    _run_changed(ucr, changed, 'I: %s will be set in scope "%s"')