Add tests for :config-dict-add, :config-dict-remove, :config-list-add and :config-list-remove with invalid option

This commit is contained in:
arza 2019-03-18 10:04:22 +02:00 committed by Florian Bruhin
parent 6f3f500404
commit 99a4f4a034
1 changed files with 24 additions and 0 deletions

View File

@ -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,