mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-05 07:56:14 +02:00
make format
This commit is contained in:
parent
99030c4623
commit
b92dd7edc7
6 changed files with 69 additions and 63 deletions
|
@ -1,41 +1,34 @@
|
|||
import pytest
|
||||
|
||||
from jrnl.override import apply_overrides, recursively_apply
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def minimal_config():
|
||||
cfg = {
|
||||
"colors":{
|
||||
"body":"red",
|
||||
"date":"green"
|
||||
},
|
||||
"default":"/tmp/journal.jrnl",
|
||||
"editor":"vim"
|
||||
def minimal_config():
|
||||
cfg = {
|
||||
"colors": {"body": "red", "date": "green"},
|
||||
"default": "/tmp/journal.jrnl",
|
||||
"editor": "vim",
|
||||
}
|
||||
yield cfg
|
||||
yield cfg
|
||||
|
||||
def test_apply_override(minimal_config):
|
||||
|
||||
def test_apply_override(minimal_config):
|
||||
config = minimal_config.copy()
|
||||
overrides = {
|
||||
'editor':'nano'
|
||||
}
|
||||
overrides = {"editor": "nano"}
|
||||
config = apply_overrides(overrides, config)
|
||||
assert config['editor']=='nano'
|
||||
assert config["editor"] == "nano"
|
||||
|
||||
def test_override_dot_notation(minimal_config):
|
||||
cfg = minimal_config.copy()
|
||||
overrides = {
|
||||
"colors.body": "blue"
|
||||
}
|
||||
|
||||
def test_override_dot_notation(minimal_config):
|
||||
cfg = minimal_config.copy()
|
||||
overrides = {"colors.body": "blue"}
|
||||
cfg = apply_overrides(overrides=overrides, base_config=cfg)
|
||||
assert cfg["colors"] == {"body": "blue", "date":"green"}
|
||||
assert cfg["colors"] == {"body": "blue", "date": "green"}
|
||||
|
||||
def test_recursive_override(minimal_config):
|
||||
|
||||
cfg = {
|
||||
"colors": {
|
||||
"body": "red",
|
||||
"title": "green"
|
||||
}
|
||||
}
|
||||
cfg = recursively_apply(cfg,["colors",'body'],"blue")
|
||||
assert cfg["colors"]["body"] == "blue"
|
||||
|
||||
def test_recursive_override(minimal_config):
|
||||
|
||||
cfg = {"colors": {"body": "red", "title": "green"}}
|
||||
cfg = recursively_apply(cfg, ["colors", "body"], "blue")
|
||||
assert cfg["colors"]["body"] == "blue"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue