Improve :config-add-(list|dict) tests
This commit is contained in:
parent
7cea4e3262
commit
927c2ff94a
@ -300,28 +300,17 @@ class TestAdd:
|
|||||||
assert yaml_value(name)[-1] == value
|
assert yaml_value(name)[-1] == value
|
||||||
|
|
||||||
def test_add_list_non_list(self, commands):
|
def test_add_list_non_list(self, commands):
|
||||||
name = 'history_gap_interval'
|
|
||||||
value = 'value'
|
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
cmdexc.CommandError,
|
cmdexc.CommandError,
|
||||||
match=":config-add-list can only be used for lists"):
|
match=":config-add-list can only be used for lists"):
|
||||||
commands.config_add_list(name, value)
|
commands.config_add_list('history_gap_interval', 'value')
|
||||||
|
|
||||||
def test_add_list_empty_value(self, commands):
|
@pytest.mark.parametrize('value', ['', None, 42])
|
||||||
name = 'content.host_blocking.whitelist'
|
def test_add_list_invalid_values(self, commands, value):
|
||||||
value = ''
|
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
cmdexc.CommandError,
|
cmdexc.CommandError,
|
||||||
match="Invalid value '{}' - may not be empty!".format(value)):
|
match="Invalid value '{}'".format(value)):
|
||||||
commands.config_add_list(name, value)
|
commands.config_add_list('content.host_blocking.whitelist', value)
|
||||||
|
|
||||||
def test_add_list_none_value(self, commands):
|
|
||||||
name = 'content.host_blocking.whitelist'
|
|
||||||
value = None
|
|
||||||
with pytest.raises(
|
|
||||||
cmdexc.CommandError,
|
|
||||||
match="Invalid value 'None' - may not be null!"):
|
|
||||||
commands.config_add_list(name, value)
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('value', ['test1', 'test2'])
|
@pytest.mark.parametrize('value', ['test1', 'test2'])
|
||||||
@pytest.mark.parametrize('temp', [True, False])
|
@pytest.mark.parametrize('temp', [True, False])
|
||||||
@ -354,29 +343,16 @@ class TestAdd:
|
|||||||
commands.config_add_dict(name, key, value, replace=False)
|
commands.config_add_dict(name, key, value, replace=False)
|
||||||
|
|
||||||
def test_add_dict_non_dict(self, commands):
|
def test_add_dict_non_dict(self, commands):
|
||||||
name = 'history_gap_interval'
|
|
||||||
key = 'value'
|
|
||||||
value = 'value'
|
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
cmdexc.CommandError,
|
cmdexc.CommandError,
|
||||||
match=":config-add-dict can only be used for dicts"):
|
match=":config-add-dict can only be used for dicts"):
|
||||||
commands.config_add_dict(name, key, value)
|
commands.config_add_dict('history_gap_interval', 'key', 'value')
|
||||||
|
|
||||||
def test_add_dict_empty_value(self, commands):
|
@pytest.mark.parametrize('value', ['', None, 42])
|
||||||
name = 'aliases'
|
def test_add_dict_invalid_values(self, commands, value):
|
||||||
key = 'missingkey'
|
|
||||||
value = ''
|
|
||||||
with pytest.raises(cmdexc.CommandError,
|
with pytest.raises(cmdexc.CommandError,
|
||||||
match="Invalid value '' - may not be empty!"):
|
match="Invalid value '{}'".format(value)):
|
||||||
commands.config_add_dict(name, key, value)
|
commands.config_add_dict('aliases', 'missingkey', value)
|
||||||
|
|
||||||
def test_add_dict_none_value(self, commands):
|
|
||||||
name = 'aliases'
|
|
||||||
key = 'missingkey'
|
|
||||||
value = None
|
|
||||||
with pytest.raises(cmdexc.CommandError,
|
|
||||||
match="Invalid value 'None' - may not be null!"):
|
|
||||||
commands.config_add_dict(name, key, value)
|
|
||||||
|
|
||||||
|
|
||||||
class TestUnsetAndClear:
|
class TestUnsetAndClear:
|
||||||
|
Loading…
Reference in New Issue
Block a user