mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-05 07:56:14 +02:00
unittest multiple overrides
This commit is contained in:
parent
36623c1100
commit
bd61a78fba
3 changed files with 28 additions and 2 deletions
|
@ -9,6 +9,10 @@ def minimal_config():
|
|||
"colors": {"body": "red", "date": "green"},
|
||||
"default": "/tmp/journal.jrnl",
|
||||
"editor": "vim",
|
||||
"journals": {
|
||||
"default": "/tmp/journals/journal.jrnl"
|
||||
}
|
||||
|
||||
}
|
||||
yield cfg
|
||||
|
||||
|
@ -26,6 +30,17 @@ def test_override_dot_notation(minimal_config):
|
|||
cfg = apply_overrides(overrides=overrides, base_config=cfg)
|
||||
assert cfg["colors"] == {"body": "blue", "date": "green"}
|
||||
|
||||
def test_multiple_overrides(minimal_config):
|
||||
overrides = {
|
||||
"colors.title": "magenta",
|
||||
"editor": "nano",
|
||||
"journals.burner": "/tmp/journals/burner.jrnl"
|
||||
} # as returned by parse_args, saved in parser.config_override
|
||||
cfg = apply_overrides(overrides, minimal_config.copy())
|
||||
assert cfg["editor"] == "nano"
|
||||
assert cfg["colors"]["title"] == "magenta"
|
||||
assert "burner" in cfg["journals"]
|
||||
assert cfg["journals"]["burner"] == "/tmp/journals/burner.jrnl"
|
||||
|
||||
def test_recursively_apply():
|
||||
cfg = {"colors": {"body": "red", "title": "green"}}
|
||||
|
@ -34,6 +49,6 @@ def test_recursively_apply():
|
|||
|
||||
|
||||
def test_get_config_node(minimal_config):
|
||||
assert len(minimal_config.keys()) == 3
|
||||
assert len(minimal_config.keys()) == 4
|
||||
assert _get_config_node(minimal_config, "editor") == "vim"
|
||||
assert _get_config_node(minimal_config, "display_format") == None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue