From 99a4f4a034b2f3460118ed8e6b80373e42e2194e Mon Sep 17 00:00:00 2001 From: arza Date: Mon, 18 Mar 2019 10:04:22 +0200 Subject: Add tests for :config-dict-add, :config-dict-remove, :config-list-add and :config-list-remove with invalid option --- tests/unit/config/test_configcommands.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/unit/config/test_configcommands.py b/tests/unit/config/test_configcommands.py index e7140bd11..1b91943c5 100644 --- a/tests/unit/config/test_configcommands.py +++ b/tests/unit/config/test_configcommands.py @@ -299,6 +299,12 @@ class TestAdd: else: assert yaml_value(name)[-1] == value + def test_list_add_invalid_option(self, commands): + with pytest.raises( + cmdutils.CommandError, + match="No option 'nonexistent'"): + commands.config_list_add('nonexistent', 'value') + def test_list_add_non_list(self, commands): with pytest.raises( cmdutils.CommandError, @@ -342,6 +348,12 @@ class TestAdd: "overwrite!"): commands.config_dict_add(name, key, value, replace=False) + def test_dict_add_invalid_option(self, commands): + with pytest.raises( + cmdutils.CommandError, + match="No option 'nonexistent'"): + commands.config_dict_add('nonexistent', 'key', 'value') + def test_dict_add_non_dict(self, commands): with pytest.raises( cmdutils.CommandError, @@ -371,6 +383,12 @@ class TestRemove: else: assert value not in yaml_value(name) + def test_list_remove_invalid_option(self, commands): + with pytest.raises( + cmdutils.CommandError, + match="No option 'nonexistent'"): + commands.config_list_remove('nonexistent', 'value') + def test_list_remove_non_list(self, commands): with pytest.raises( cmdutils.CommandError, @@ -396,6 +414,12 @@ class TestRemove: else: assert key not in yaml_value(name) + def test_dict_remove_invalid_option(self, commands): + with pytest.raises( + cmdutils.CommandError, + match="No option 'nonexistent'"): + commands.config_dict_remove('nonexistent', 'key') + def test_dict_remove_non_dict(self, commands): with pytest.raises( cmdutils.CommandError, -- cgit v1.2.3-54-g00ecf