From 999d70ae40cf52ee29b4fcb6ca15fc5df8d06187 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 3 Oct 2017 14:12:29 +0200 Subject: [PATCH] Add missing config.py tests --- tests/unit/config/test_config.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index f1bed1060..03fa1dbae 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -20,6 +20,7 @@ import copy import types +import unittest.mock import pytest from PyQt5.QtCore import QObject @@ -262,6 +263,11 @@ class TestConfig: yaml_config = configfiles.YamlConfig() return config.Config(yaml_config) + def test_init_save_manager(self, conf, fake_save_manager): + conf.init_save_manager(fake_save_manager) + fake_save_manager.add_saveable.assert_called_once_with( + 'yaml-config', unittest.mock.ANY, unittest.mock.ANY) + def test_set_value(self, qtbot, conf, caplog): opt = conf.get_opt('tabs.show') with qtbot.wait_signal(conf.changed) as blocker: @@ -432,6 +438,19 @@ class TestConfig: assert not conf._mutables assert conf.get_obj(option) == new + def test_get_mutable_twice(self, conf): + """Get a mutable value twice.""" + option = 'content.headers.custom' + obj = conf.get_obj(option, mutable=True) + obj['X-Foo'] = 'fooval' + obj2 = conf.get_obj(option, mutable=True) + obj2['X-Bar'] = 'barval' + + conf.update_mutables() + + expected = {'X-Foo': 'fooval', 'X-Bar': 'barval'} + assert conf.get_obj(option) == expected + def test_get_obj_unknown_mutable(self, conf): """Make sure we don't have unknown mutable types.""" conf._values['aliases'] = set() # This would never happen