Need to mark config as dirty in _handle_migrations()

Add tests for tabs.persist_mode_on_change migration
This commit is contained in:
Marc Jauvin 2018-02-09 14:41:33 -05:00
parent 4e2e2606ef
commit 9b7db8ee8a
2 changed files with 25 additions and 2 deletions

View File

@ -179,14 +179,13 @@ class YamlConfig(QObject):
elif name in configdata.MIGRATIONS.deleted:
log.config.debug("Removing {}".format(name))
del self._values[name]
persist = 'tabs.persist_mode_on_change'
if persist in self._values:
if self._values[persist]:
self._values['tabs.mode_on_change'] = 'persist'
else:
self._values['tabs.mode_on_change'] = 'normal'
del self._values[persist]
self.unset(persist)
def _validate(self):
"""Make sure all settings exist."""

View File

@ -169,6 +169,30 @@ class TestYaml:
assert ' old:' not in lines
assert ' new:' not in lines
def test_merge_persist_false(self, monkeypatch, yaml, config_tmpdir):
"""Migration of tabs.persist_mode_on_change: False."""
autoconfig = config_tmpdir / 'autoconfig.yml'
autoconfig.write_text('global:\n tabs.persist_mode_on_change: False', encoding='utf-8')
yaml.load()
yaml._save()
lines = autoconfig.read_text('utf-8').splitlines()
assert ' tabs.persist_mode_on_change:' not in lines
assert ' tabs.mode_on_change: normal' in lines
def test_merge_persist_true(self, monkeypatch, yaml, config_tmpdir):
"""Migration of tabs.persist_mode_on_change: True."""
autoconfig = config_tmpdir / 'autoconfig.yml'
autoconfig.write_text('global:\n tabs.persist_mode_on_change: True', encoding='utf-8')
yaml.load()
yaml._save()
lines = autoconfig.read_text('utf-8').splitlines()
assert ' tabs.persist_mode_on_change:' not in lines
assert ' tabs.mode_on_change: persist' in lines
def test_renamed_key_unknown_target(self, monkeypatch, yaml,
config_tmpdir):
"""A key marked as renamed with invalid name should raise an error."""