diff options
author | Milo Gertjejansen <milo@milogert.com> | 2018-10-10 20:23:44 -0500 |
---|---|---|
committer | Milo Gertjejansen <milo@milogert.com> | 2018-10-10 20:23:44 -0500 |
commit | 9fd57b9be00309980be411328114f2f8b0264c4e (patch) | |
tree | 991d030e172656c42bd417988008a00710ebb9ca /tests/unit/config/test_configcommands.py | |
parent | 3e07c4ce0fd9d45ada4aef5eeb2440c619d60196 (diff) | |
download | qutebrowser-9fd57b9be00309980be411328114f2f8b0264c4e.tar.gz qutebrowser-9fd57b9be00309980be411328114f2f8b0264c4e.zip |
New config: More powerful :config- commands: remove
- `:config-remove-list` command to remove items from a list.
- `:config-remove-dict` command to remove items from a dict.
- Test coverage.
Continues #2794
Diffstat (limited to 'tests/unit/config/test_configcommands.py')
-rw-r--r-- | tests/unit/config/test_configcommands.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/unit/config/test_configcommands.py b/tests/unit/config/test_configcommands.py index 249357010..4bf3b7691 100644 --- a/tests/unit/config/test_configcommands.py +++ b/tests/unit/config/test_configcommands.py @@ -355,6 +355,61 @@ class TestAdd: commands.config_add_dict('aliases', 'missingkey', value) +class TestRemove: + + """Test :config-add-list and :config-add-dict.""" + + @pytest.mark.parametrize('value', ['25%', '50%']) + @pytest.mark.parametrize('temp', [True, False]) + def test_remove_list(self, commands, config_stub, yaml_value, value, temp): + name = 'zoom.levels' + commands.config_remove_list(name, value, temp=temp) + + assert value not in config_stub.get(name) + if temp: + assert yaml_value(name) == configutils.UNSET + else: + assert value not in yaml_value(name) + + def test_remove_list_non_list(self, commands): + with pytest.raises( + cmdexc.CommandError, + match=":config-remove-list can only be used for lists"): + commands.config_remove_list('content.javascript.enabled', + 'never') + + def test_remove_list_no_value(self, commands): + with pytest.raises( + cmdexc.CommandError, + match="never is not in colors.completion.fg!"): + commands.config_remove_list('colors.completion.fg', 'never') + + @pytest.mark.parametrize('key', ['w', 'q']) + @pytest.mark.parametrize('temp', [True, False]) + def test_remove_dict(self, commands, config_stub, yaml_value, key, temp): + name = 'aliases' + commands.config_remove_dict(name, key, temp=temp) + + assert key not in config_stub.get(name) + if temp: + assert yaml_value(name) == configutils.UNSET + else: + assert key not in yaml_value(name) + + def test_remove_dict_non_dict(self, commands): + with pytest.raises( + cmdexc.CommandError, + match=":config-remove-dict can only be used for dicts"): + commands.config_remove_dict('content.javascript.enabled', + 'never') + + def test_remove_dict_no_value(self, commands): + with pytest.raises( + cmdexc.CommandError, + match="never is not in aliases!"): + commands.config_remove_dict('aliases', 'never') + + class TestUnsetAndClear: """Test :config-unset and :config-clear.""" |